package com.whut.service.impl;

import java.lang.Object;

import cn.hutool.core.collection.ListUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whut.mapper.*;
import com.whut.model.*;
import com.whut.service.CheckInfoService;
import com.whut.utils.FileUtil;
import com.whut.utils.MDoc;
import com.whut.utils.pointsCalculate;
import com.whut.v_model.PCDandUSERNAME;
import com.whut.v_model.ProblemCollectDetail;
import com.whut.v_vo.*;
import org.apache.commons.lang3.StringUtils;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtils;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;
import org.springframework.stereotype.Service;

import java.awt.*;
import java.io.File;
import java.io.UnsupportedEncodingException;
import javax.annotation.Resource;
import java.text.*;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;

@Service("checkInfoService")
public class CheckInfoServiceImpl implements CheckInfoService {
    @Resource
    private ContractchecktaskMapper contractchecktaskMapper;
    @Resource
    private ContracttaskprojectMapper contracttaskprojectMapper;
    @Resource
    private EquipinfoMapper equipinfoMapper;
    @Resource
    private ProblemCollectDetailMapper problemCollectDetailMapper;
    @Resource
    private NewProblemCollectDetailMapper newProblemCollectDetailMapper;
    @Resource
    private NewprefixsystemMapper newprefixsystemMapper;
    @Resource
    private ProblemdescriptionMapper problemdescriptionMapper;
    @Resource
    private SummaryMapper summaryMapper;
    @Resource
    private UncheckeditemsMapper uncheckeditemsMapper;
    @Resource
    private ContractinfoMapper contractinfoMapper;
    @Resource
    private PointlimitMapper pointlimitMapper;
    @Resource
    private AllpointsaveMapper allpointsaveMapper;
    @Resource
    private ProblemcollectMapper problemcollectMapper;
    @Resource
    private  NoproblemitemMapper noproblemitemMapper;
    @Resource
    private EditableweightpsMapper editableweightpsMapper;
    @Resource
    private NewproblemdescriptionMapper newproblemdescriptionMapper;
    @Resource
    private ResultsinglechildMapper resultsinglechildMapper;
    @Resource
    private NewfuzzyresultMapper newfuzzyresultMapper;
    @Resource
    private UncheckSysPointMapper uncheckSysPointMapper;
    @Resource
    private PrefixsystemMapper prefixsystemMapper;
    @Resource
    private UrlProperties urlProperties;
    @Resource
    private Profiles profiles;
    public static final String IMG_PATH="D:\\whutServer\\generatedCharts\\";

    public static final String TEST_IMG_PATH=IMG_PATH+"test.png";

    @Override
    public Object getCheckInfoByPage(String startTime, String endTime, int curPage, int pageSize, String checkState,
                                     String startTimeY, String endTimeY, int client,String projectName) {
        PageHelper.startPage(curPage, pageSize);
        List<ContractCheckTask> list = new ArrayList<ContractCheckTask>();
        if (checkState.equals("1")) {
            switch (client) {
                case 0:
                    list = contractchecktaskMapper.getTaskByFinishTime(startTime, endTime,projectName);
                    break;
                default:
                    list = contractchecktaskMapper.getTaskByFinishTimeAndClient(startTime, endTime, client,projectName);
                    break;
            }
        } else if (checkState.equals("N")) {
            switch (client) {
                case 0:
                    list = contractchecktaskMapper.getTaskByCheckState(startTime, endTime, checkState,projectName);
                    break;
                default:
                    list = contractchecktaskMapper.getTaskByCheckStateAndClient(startTime, endTime, checkState, client,projectName);
                    break;
            }
        } else if (checkState.equals("Y")) {
            switch (client) {
                case 0:
                    list = contractchecktaskMapper.getTaskByCheckStateY(startTimeY, endTimeY, checkState,projectName);
                    break;
                default:
                    list = contractchecktaskMapper.getTaskByCheckStateYAndClient(startTime, endTime, checkState, client,projectName);
                    break;
            }
        }
        PageInfo result = new PageInfo(list);
        return result;
    }

    @Override
    public String test() throws UnsupportedEncodingException {

        Map<String, Object> dataMap = new HashMap<String, Object>();
        List<Object> list=new ArrayList<>();
        for(int i=0;i<10;i++)
        {
            Map<String,Object> map1=new HashMap<>();
            dataMap.put("pic1",1);
        }
        MDoc mdoc = new MDoc();
        mdoc.createDoc(dataMap, "D:\\WYH.doc", "ftl\\test.ftl");
        String result = "D:\\heihei.doc";
        System.out.println("成功生成模板");
        return result;

    }

    /**
     * 生成报告模块
     * @param projectId
     * @param checkId
     * @param reportType
     * @return
     * @throws Exception
     */
    @Override
    public String  generateCheckReport(int projectId, int checkId, int reportType) throws Exception {
        StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
        //设置标题字体
        standardChartTheme.setExtraLargeFont(new Font("隶书", Font.BOLD, 20));
        //设置图例的字体
        standardChartTheme.setRegularFont(new Font("宋书", Font.PLAIN, 15));
        //设置轴向的字体
        standardChartTheme.setLargeFont(new Font("宋书", Font.PLAIN, 15));
        //应用主题样式
        DecimalFormat df = new DecimalFormat("0.00");
        int width = 718;
        int height = 468;
        ChartFactory.setChartTheme(standardChartTheme);
        Map<String, Object> dataMap = new HashMap<String, Object>();
        Date date = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        DateFormat d2 = new SimpleDateFormat("yyyy");
        DateFormat d3 = new SimpleDateFormat("MM");
        DateFormat d4 = new SimpleDateFormat("dd");
        String day = d4.format(date);
        String month = d3.format(date);
        String year = d2.format(date);
        String fileName = d1.format(date);
        String zlWeight = prefixsystemMapper.getWeight1ByName1("质量检查");
        String aqWeight = prefixsystemMapper.getWeight1ByName1("安全检查");
        String glWeight = prefixsystemMapper.getWeight1ByName1("管理行为");
        dataMap.put("zlWeight", zlWeight);
        dataMap.put("aqWeight", aqWeight);
        dataMap.put("glWeight", glWeight);
        dataMap.put("day", day);
        dataMap.put("month", month);
        dataMap.put("year", year);
        dataMap.put("zlPoint", "\\");
        dataMap.put("glPoint", "\\");
        dataMap.put("aqPoint", "\\");
        dataMap.put("zlLever", "\\");
        dataMap.put("aqLever", "\\");
        dataMap.put("glLever", "\\");
        DefaultPieDataset datasetPie = new DefaultPieDataset();
        DefaultCategoryDataset datasetBar = new DefaultCategoryDataset();
        final String Bar = "各检查分项";
        //工程概况部分，来自ctp的工程信息
        List<ContractTaskProject> projectList = contracttaskprojectMapper.selectAllByCheckId(projectId);
        String project = JSON.toJSONString(projectList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        System.out.println(project);
        JSONArray projectArray = JSONArray.parseArray(project);
        JSONObject projectObject = projectArray.getJSONObject(0);
        dataMap.put("projectName", projectObject.getString("projectName"));
        dataMap.put("projectAddress", projectObject.getString("area"));
        dataMap.put("jsUnit", projectObject.getString("jsUnit"));
        dataMap.put("jlUnit", projectObject.getString("jlUnit"));
        dataMap.put("sgUnit", projectObject.getString("sgUnit"));
        dataMap.put("projectType", projectObject.getString("projectType"));
        dataMap.put("projectPrice", projectObject.getString("projectPrice"));
        dataMap.put("dangerItem", projectObject.getString("dangerItem"));
        dataMap.put("remark", projectObject.getString("remark"));
        dataMap.put("projectDescription", projectObject.getString("projectDescription"));
        String js = projectObject.getString("jsUniter");
        String jl = projectObject.getString("jlUniter");
        String sg = projectObject.getString("manager");
        dataMap.put("jsUniter", js);
        dataMap.put("jlUniter", jl);
        dataMap.put("sgUniter", sg);
        //工程概况部分，来自设备信息表的设备信息部分
        List<Equipinfo> equipinfoList = equipinfoMapper.getAllByProjectId(projectId);
        String equip = JSON.toJSONString(equipinfoList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray equipArray = JSONArray.parseArray(equip);
        List<Object> equipList = new ArrayList<Object>();
        if (equipArray.size() == 0) {
            Map<String, Object> eqMap = new HashMap<String, Object>();
            eqMap.put("equipType", "\\");
            eqMap.put("equipQua", "\\");
            eqMap.put("equipNum", "\\");
            eqMap.put("equipLeaseUnit", "\\");
            eqMap.put("equipUseUnit", "\\");
            eqMap.put("demolitionUnit", "\\");
            eqMap.put("testUnit", "\\");
            equipList.add(eqMap);
        } else {
            for (int i = 0; i < equipArray.size(); i++) {
                Map<String, Object> eqMap = new HashMap<String, Object>();
                JSONObject equipObject = equipArray.getJSONObject(i);
                eqMap.put("equipType", equipObject.getString("equipType"));
                eqMap.put("equipQua", equipObject.getString("equipQua"));
                eqMap.put("equipNum", equipObject.getString("equipNum"));
                eqMap.put("equipLeaseUnit", equipObject.getString("equipLeaseUnit"));
                eqMap.put("equipUseUnit", equipObject.getString("equipUseUnit"));
                eqMap.put("demolitionUnit", equipObject.getString("demolitionUnit"));
                eqMap.put("testUnit", equipObject.getString("testUnit"));
                equipList.add(eqMap);
            }
        }
        dataMap.put("equipList", equipList);
        //第一部分，综合评估结果，从合同任务检查表中获取相关信息,签名部分
        List<ContractCheckTask> checkInfo = contractchecktaskMapper.getCheckInfoByCheckId(checkId);
        String check = JSON.toJSONString(checkInfo, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray checkArray = JSONArray.parseArray(check);
        JSONObject checkObject = checkArray.getJSONObject(0);

//        dataMap.put("jsSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png"));
//        dataMap.put("jlSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png"));
//        dataMap.put("sgSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png"));
//        dataMap.put("jsSign", MDoc.getImageStr("C:\\Users\\96500\\Desktop\\20190329183836002.png"));
//        dataMap.put("jlSign", MDoc.getImageStr("C:\\Users\\96500\\Desktop\\20190329183836002.png"));
//        dataMap.put("sgSign", MDoc.getImageStr("C:\\Users\\96500\\Desktop\\20190329183836002.png"));
        String signPicPath = checkObject.getString("signPath");
        String jsSign = checkObject.getString("jsSign");
        String jlSign = checkObject.getString("jlSign");
        String sgSign = checkObject.getString("sgSign");

        String imgFile =IMG_PATH+"blank.png";
        String imgFileStr;
        if(!MDoc.isFoundImageStr(imgFile)){
            imgFile=TEST_IMG_PATH;
        }
        if ( (signPicPath==null || signPicPath.equals(""))) {
            imgFileStr=MDoc.getImageStr(imgFile);
            dataMap.put("jsSign", imgFileStr);
            dataMap.put("jlSign", imgFileStr);
            dataMap.put("sgSign", imgFileStr);
        } else {
            dataMap.put("jsSign", MDoc.getImageStr(signPicPath + jsSign));
            dataMap.put("jlSign", MDoc.getImageStr(signPicPath + jlSign));
            dataMap.put("sgSign", MDoc.getImageStr(signPicPath + sgSign));
        }




        //第一部分，（二）分项评估结果
        List<Object> pName1Info = problemCollectDetailMapper.getAllName1Id(checkId);
        String name1 = JSON.toJSONString(pName1Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray name1Array = JSONArray.parseArray(name1);   //firstId
        float allExtraPointFloat = problemCollectDetailMapper.getAllExtraPoint(checkId);
        double allExtraPoint = Double.valueOf(String.valueOf(allExtraPointFloat));
        double overAllPoint = 0;
        Integer taskId = contractchecktaskMapper.getTaskIdByCheckId(checkId);
        List<Object> part2List = new ArrayList<Object>();
        String Name1 = "";
        double allweight1 = 0;
        for (int i = 0; i < name1Array.size(); i++) {
            double Tweight1 = 0;
            String weight1 = prefixsystemMapper.getWeight1ByName1(prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(i)));
            Tweight1 = pointsCalculate.getPercentInstance(weight1);
            allweight1 += Tweight1;
        }
        for (int k = 0; k < name1Array.size(); k++) {
            Map<String, Object> part2Map = new HashMap<String, Object>();
            List<Object> part2InnerList = new ArrayList<Object>();
            String pName1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(k)); //通过firstId找到pName1
            double Tweight1 = 0;
            String weight1 = prefixsystemMapper.getWeight1ByName1(pName1);  //获取权重
            Tweight1 = pointsCalculate.getPercentInstance(weight1);
            if (pName1.equals("安全检查")) {
                List<ProblemCollectDetail> list = problemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("aqLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "安全文明";
            } else if (pName1.equals("质量检查")) {
                List<ProblemCollectDetail> list = problemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("zlLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "质量隐患";
            } else if (pName1.equals("管理行为")) {
                List<ProblemCollectDetail> list = problemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("glLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "管理行为";
            }
            part2Map.put("name1No", k + 1);
            part2Map.put("name1", Name1);
            List<Object> secondIdList = problemCollectDetailMapper.getSecondId(checkId, pName1);  //获取secondIdList
            String secondIdInfo = JSON.toJSONString(secondIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray secondIdInfoArray = JSONArray.parseArray(secondIdInfo);
            double allweight2 = 0;
            for (int p = 0; p < secondIdInfoArray.size(); p++) {
                int allsecondId = secondIdInfoArray.getIntValue(p);
                String weight2 = prefixsystemMapper.getWeight3ByThirdId(allsecondId);
                double weight22 = pointsCalculate.getPercentInstance(weight2);
                allweight2 += weight22;
            }
            double allsecondPoint = 0;
            for (int u = 0; u < secondIdInfoArray.size(); u++) {
                int secondId = secondIdInfoArray.getIntValue(u);
                double weight222 = 0;
                String weight2 = prefixsystemMapper.getWeight3ByThirdId(secondId); //获取第三级权重的weight
                weight222 = pointsCalculate.getPercentInstance(weight2);
                double point = 0;

                List<ProblemCollectDetail> fourthPoints = problemCollectDetailMapper.getFourthPoint(checkId, pName1, secondId);
                String fourthCalculateInfo = JSON.toJSONString(fourthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray fourthPointsCalculateArray = JSONArray.parseArray(fourthCalculateInfo);
                List<ProblemCollectDetail> noProblemItemList = problemCollectDetailMapper.getNoProblemItem(checkId, secondId);
                String noProblemCalculateInfo = JSON.toJSONString(noProblemItemList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray noProblemCalculateArray = JSONArray.parseArray(noProblemCalculateInfo);
                for (int j = 0; j < noProblemCalculateArray.size(); j++) {
                    Map<String, Object> part2InnerMap = new HashMap<String, Object>();
                    JSONObject part2InnerObject = noProblemCalculateArray.getJSONObject(j);
                    part2InnerMap.put("pName4", "无问题项");

                    double allweight4 = this.calculateAllWeight4Func(checkId, part2InnerObject);
                    double weight3 = 0;
                    double weight4 = 0;
                    int part2FourthId = part2InnerObject.getIntValue("fourthId");
                    int part2ThirdId = part2InnerObject.getIntValue("thirdId");
                    weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
                    weight4 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight4"));
                    String weight4Result = this.getPart2InnerListweight4(checkId, part2ThirdId, weight3, weight4, allweight4);
                    part2InnerMap.put("weight4", weight4Result);

                    List<ProblemCollectDetail> sixthPoints = problemCollectDetailMapper.getsixthPoints(checkId, part2FourthId);
                    String pointName6Info = JSON.toJSONString(sixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray sixthPointsArray = JSONArray.parseArray(pointName6Info);
                    double calculatePoint6 = 0;
                    double calculateTruePoint = 0;
                    List<Double> calculatePointList = this.calculatePoint6Func(sixthPointsArray, checkId);
                    calculatePoint6 = calculatePointList.get(0);
                    calculateTruePoint = calculatePointList.get(1);
                    double noProblemPoint = this.calculateNoProblemPointFunc(checkId, part2InnerObject);
                    System.out.println("第六级扣过的分数总分:" + calculatePoint6 + "没有问题的总分:" + noProblemPoint + "第六级总分:" + calculateTruePoint);
                    double checkItemPoint = (calculatePoint6 + noProblemPoint) / (calculateTruePoint + noProblemPoint) * 100;
                    String s = this.getCheckItemPointAndUpdateAllPointSave(checkId, part2FourthId, projectId, checkItemPoint, df);

                    part2InnerMap.put("checkItemPoint", s);
                    //point += checkItemPoint * weight3 / countFourthId;
                    //point += checkItemPoint * weight3 / (allweight4/weight4);
                    part2InnerList.add(part2InnerMap);
                }
                for (int j = 0; j < fourthPointsCalculateArray.size(); j++) {
                    Map<String, Object> part2InnerMap = new HashMap<String, Object>();
                    JSONObject part2InnerObject = fourthPointsCalculateArray.getJSONObject(j);
                    part2InnerMap.put("pName4", part2InnerObject.getString("pName4"));

                    double allweight4 = this.calculateAllWeight4Func(checkId, part2InnerObject);
                    double weight3 = 0;
                    double weight4 = 0;
                    int part2FourthId = part2InnerObject.getIntValue("fourthId");
                    int part2ThirdId = part2InnerObject.getIntValue("thirdId");
//                    weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
//                    weight4 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight4"));
                    String newWeight4 = editableweightpsMapper.getWeightByNumber(part2FourthId,taskId);
                    if(StringUtils.isNotBlank(newWeight4)){
                        weight4 = pointsCalculate.getPercentInstance(newWeight4);
                    }else {
                        weight4 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight4"));
                    }
                    String newWeight3 = editableweightpsMapper.getWeightByNumber(part2ThirdId,taskId);
                    if(StringUtils.isNotBlank(newWeight3)){
                        weight3 = pointsCalculate.getPercentInstance(newWeight3);
                    }else {
                        weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
                    }

                    String weight4Result = this.getPart2InnerListweight4(checkId, part2ThirdId, weight3, weight4, allweight4);
                    part2InnerMap.put("weight4", weight4Result);

                    List<ProblemCollectDetail> sixthPoints = problemCollectDetailMapper.getsixthPoints(checkId, part2FourthId);
                    String pointName6Info = JSON.toJSONString(sixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray sixthPointsArray = JSONArray.parseArray(pointName6Info);
                    double calculatePoint6 = 0;
                    double calculateTruePoint = 0;
                    List<Double> calculatePointList = this.calculatePoint6Func(sixthPointsArray, checkId);
                    calculatePoint6 = calculatePointList.get(1);
                    calculateTruePoint = calculatePointList.get(0);
                    double noProblemPoint = this.calculateNoProblemPointFunc(checkId, part2InnerObject);
                    System.out.println("第六级扣过的分数总分:" + calculatePoint6 + "没有问题的总分:" + noProblemPoint + "第六级总分:" + calculateTruePoint);
                    double checkItemPoint = (calculatePoint6 + noProblemPoint) / (calculateTruePoint + noProblemPoint) * 100;
                    String s = this.getCheckItemPointAndUpdateAllPointSave(checkId, part2FourthId, projectId, checkItemPoint, df);

                    part2InnerMap.put("checkItemPoint", s);
                    //point += checkItemPoint * weight3 / countFourthId;
                    point += checkItemPoint * weight3 / (allweight4/weight4);
                    //System.out.println("这里可能有问题："+point+" "+j+" " +checkItemPoint+" "+weight3+ " "+allweight4+" "+weight4);
                    part2InnerList.add(part2InnerMap);
                }

                List<Object> getThirdId = problemCollectDetailMapper.getThirdId(checkId, pName1, secondId);
                String thirdIdInfo = JSON.toJSONString(getThirdId, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray thirdArray = JSONArray.parseArray(thirdIdInfo);

                double allweight3 = 0;
                for (int v = 0; v < thirdArray.size(); v++) {
                    double Tweight3 = 0;
                    int thirdId = thirdArray.getIntValue(v);

//                    String trueweight3 = prefixsystemMapper.getWeight3ByThirdId(thirdId);
//                    Tweight3 = pointsCalculate.getPercentInstance(trueweight3);

                    String newWeight3 = editableweightpsMapper.getWeightByNumber(thirdId, taskId);
                    if (StringUtils.isNotBlank(newWeight3)){
                        Tweight3 = pointsCalculate.getPercentInstance(newWeight3);
                    }else{
                        String trueweight3 = prefixsystemMapper.getWeight3ByThirdId(thirdId);
                        Tweight3 = pointsCalculate.getPercentInstance(trueweight3);
                    }

                    allweight3 += Tweight3;
                }
                System.out.println(point+"dasdasdadasd"+allweight3+"dasdsadsadad"+df.format(point / allweight3));
                double thirdPoint = Double.parseDouble(df.format(point / allweight3));
                double percent2 = Double.parseDouble(df.format(weight222 / allweight2));
                double secondPoint = Double.parseDouble(df.format(thirdPoint * percent2));
                allsecondPoint += secondPoint;
            }

            if (pName1.equals("安全检查")) {
                dataMap.put("aqPoint", allsecondPoint);
            } else if (pName1.equals("质量检查")) {
                dataMap.put("zlPoint", allsecondPoint);
            } else if (pName1.equals("管理行为")) {
                dataMap.put("glPoint", allsecondPoint);
            }
            int firstPointCount = allpointsaveMapper.getAllPointCountByCheckId(checkId, name1Array.getInteger(k));
            if (firstPointCount != 0) {
                SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                Date date1 = new Date(System.currentTimeMillis());
                String lastEditTime=formatter.format(date1);
                allpointsaveMapper.updateAllPoint(checkId, df.format(allsecondPoint), name1Array.getInteger(k),lastEditTime);
            } else {
                Allpointsave allpointsave = new Allpointsave();
                SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                Date date1 = new Date(System.currentTimeMillis());
                allpointsave.setNewCreateTime(formatter.format(date1));
                allpointsave.setLastEditTime(formatter.format(date1));
                allpointsave.setCheckId(checkId);
                allpointsave.setNumber(name1Array.getInteger(k));
                allpointsave.setPoint(df.format(allsecondPoint));
                allpointsave.setProjectId(projectId);
                allpointsaveMapper.insert(allpointsave);
            }
            double trueWeight1 = Double.parseDouble(df.format(Tweight1 / allweight1));
            overAllPoint += Double.parseDouble(df.format(trueWeight1 * allsecondPoint));
            part2Map.put("point", allsecondPoint);
            part2Map.put("part2InnerList", part2InnerList);
            part2List.add(part2Map);
        }
        overAllPoint = overAllPoint - allExtraPoint;
        dataMap.put("overAllPoint", overAllPoint);
        //将总分存到ALLPOINTSAVE中
        int allPointInDB = allpointsaveMapper.getAllPointCountByCheckId(checkId, -1);
        if (allPointInDB != 0) {
            SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
            Date date1 = new Date(System.currentTimeMillis());
            String lastEditTime=formatter.format(date1);
            allpointsaveMapper.updateAllPoint(checkId, df.format(overAllPoint), -1,lastEditTime);
        } else {
            Allpointsave allpointsave = new Allpointsave();
            SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
            Date date1 = new Date(System.currentTimeMillis());
            allpointsave.setNewCreateTime(formatter.format(date1));
            allpointsave.setLastEditTime(formatter.format(date1));
            allpointsave.setCheckId(checkId);
            allpointsave.setNumber(-1);
            allpointsave.setProjectId(projectId);
            allpointsave.setPoint(df.format(overAllPoint));
            allpointsaveMapper.insert(allpointsave);
        }
        //将总分存到CCT表中
        ContractCheckTask contractchecktask = new ContractCheckTask();
        SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
        Date date1 = new Date(System.currentTimeMillis());
        contractchecktask.setLastEditTime(formatter.format(date1));
        contractchecktask.setCheckId(checkId);
        contractchecktask.setTotalPoint(String.valueOf(overAllPoint));
        contractchecktaskMapper.updateByPrimaryKeySelective(contractchecktask);

        List<ProblemCollectDetail> overallList = problemCollectDetailMapper.getAllProblemCollectInfoByCheckId(checkId);
        dataMap.put("overAllLever", pointsCalculate.getMaxRiskPoint(overallList));
        ContractTaskProject contractTaskProjectRiskPoint = new ContractTaskProject();
        contractTaskProjectRiskPoint.setProjectId(projectId);
        contractTaskProjectRiskPoint.setLatestRiskLevel(pointsCalculate.getMaxRiskPoint(overallList));
        contractTaskProjectRiskPoint.setLastEditTime(formatter.format(date1));
        contracttaskprojectMapper.updateByPrimaryKeySelective(contractTaskProjectRiskPoint);
        ContractTaskProject newRiskList = contracttaskprojectMapper.selectByPrimaryKey(projectId);
        String finishTime = contractchecktaskMapper.getFinishTimeByCheckId(checkId);
        if (newRiskList.getCheckTime().equals("") || newRiskList.getCheckTime().compareTo(finishTime) <= 0) {
            try {
                ContractTaskProject contracttaskproject = new ContractTaskProject();
                contracttaskproject.setProjectId(projectId);
                contracttaskproject.setLatestCheckTime(finishTime);
                contracttaskproject.setLastEditTime(formatter.format(date1));
                contracttaskprojectMapper.updateByPrimaryKeySelective(contracttaskproject);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        dataMap.put("part2List", part2List);

        //第一部分，（三）各个专业问题的分布情况
        List<Object> pName4Info = problemCollectDetailMapper.getAllName4(checkId);
        int allProblemNum = problemCollectDetailMapper.getAllNum(checkId);
        dataMap.put("allProblemNum", allProblemNum);
        String name4 = JSON.toJSONString(pName4Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray name4Array = JSONArray.parseArray(name4);
        List<Object> part3List = new ArrayList<Object>();
        for (int m = 0; m < name4Array.size(); m++) {
            Map<String, Object> part3Map = new HashMap<String, Object>();
            int pName4Id = name4Array.getIntValue(m);
            String pName4 = prefixsystemMapper.getName4ByName4Id(pName4Id);
            int name4Num = problemCollectDetailMapper.countName4(pName4Id, checkId);
            String percent = pointsCalculate.caculateToPercent(name4Num, allProblemNum);
            part3Map.put("No", m + 1);
            part3Map.put("name4", pName4);
            part3Map.put("problemNum", name4Num);
            part3Map.put("percent", percent);
            datasetPie.setValue(pName4 + ":" + percent, new Double(name4Num));
            datasetBar.addValue(name4Num, Bar, pName4);
            part3List.add(part3Map);
        }
        dataMap.put("part3List", part3List);

        //第一部分，三.检查问题综述
        if (reportType == 1) {
            List<Object> part4List = new ArrayList<Object>();
            for (int i = 0; i < name1Array.size(); i++) {
                List<Object> part4InnerList = new ArrayList<Object>();
                Map<String, Object> part4Map = new HashMap<String, Object>();
                String pName1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(i));
                List<Summary> summaryList = summaryMapper.getSummaryInfo(checkId, name1Array.getIntValue(i));
                String summaryInfo = JSON.toJSONString(summaryList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray summaryInfoArray = JSONArray.parseArray(summaryInfo);
                for (int j = 0; j < summaryInfoArray.size(); j++) {
                    Map<String, Object> part4InnerMap = new HashMap<String, Object>();
                    JSONObject part4InnerObject = summaryInfoArray.getJSONObject(j);
                    String part4pNname4 = prefixsystemMapper.getName4ByName4Id(part4InnerObject.getIntValue("fourthId"));
                    part4InnerMap.put("pName4", part4pNname4);
                    part4InnerMap.put("summary", part4InnerObject.getString("summary"));
                    part4InnerList.add(part4InnerMap);
                }
                if (pName1.equals("安全检查")) {
                    part4Map.put("name1", "安全");
                } else if (pName1.equals("质量检查")) {
                    part4Map.put("name1", "新质量");
                } else if (pName1.equals("管理行为")) {
                    part4Map.put("name1", "管理");
                } else if (pName1.equals("设备检查")) {
                    part4Map.put("name1", "检查");
                }
                part4Map.put("part4InnerList", part4InnerList);
                part4List.add(part4Map);
            }
            dataMap.put("part4List", part4List);
        } else if (reportType == 2) {
            List<Object> partProblemList = new ArrayList<Object>();
            for (int i = 0; i < name1Array.size(); i++) {
                List<Object> partProblemName1List = new ArrayList<Object>();
                Map<String, Object> partProblemMap = new HashMap<String, Object>();
                String pName1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(i));
                List<Object> problemName4List = problemCollectDetailMapper.getAllName4ByName1(checkId, pName1);
                String problemName4Info = JSON.toJSONString(problemName4List, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray problemName4Array = JSONArray.parseArray(problemName4Info);
                for (int k = 0; k < problemName4Array.size(); k++) {
                    List<ProblemCollectDetail> partProblemDetailList = problemCollectDetailMapper.getAllFourthInfo(checkId, problemName4Array.getIntValue(k));
                    String partProblemDetailInfo = JSON.toJSONString(partProblemDetailList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray partProblemDetailArray = JSONArray.parseArray(partProblemDetailInfo);
                    String problemName4 = prefixsystemMapper.getName4ByName4Id(problemName4Array.getIntValue(k));
                    for (int j = 0; j < partProblemDetailArray.size(); j++) {
                        Map<String, Object> partProblemName1Map = new HashMap<String, Object>();
                        JSONObject partProblemObject = partProblemDetailArray.getJSONObject(j);
                        String problemDescription = partProblemObject.getString("problemDescription");
                        String riskPoint = partProblemObject.getString("riskPoint");
                        if (partProblemObject.getString("isRemark").equals("N")) {
                            partProblemName1Map.put("problemDescription", problemDescription);
                        } else if (partProblemObject.getString("isRemark").equals("Y")) {
                            partProblemName1Map.put("problemDescription", partProblemObject.getString("remark"));
                        }
                        partProblemName1Map.put("riskPoint", riskPoint);
                        partProblemName1Map.put("name4", problemName4);
                        partProblemName1List.add(partProblemName1Map);
                    }
                }
                if (pName1.equals("安全检查")) {
                    partProblemMap.put("name1", "安全");
                } else if (pName1.equals("质量检查")) {
                    partProblemMap.put("name1", "质量");
                } else if (pName1.equals("管理行为")) {
                    partProblemMap.put("name1", "管理行为");
                }
                partProblemMap.put("partProblemName1List", partProblemName1List);
                partProblemList.add(partProblemMap);
            }
            dataMap.put("partProblemList", partProblemList);
            int txNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "提醒");
            int oneNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "1");
            int twoNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "2");
            int threeNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "3");
            int fourNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "4");
            dataMap.put("txNum", txNum);
            dataMap.put("oneNum", oneNum);
            dataMap.put("twoNum", twoNum);
            dataMap.put("threeNum", threeNum);
            dataMap.put("fourNum", fourNum);
            String txPercent = pointsCalculate.caculateToPercent(txNum, allProblemNum);
            String onePercent = pointsCalculate.caculateToPercent(oneNum, allProblemNum);
            String twoPercent = pointsCalculate.caculateToPercent(twoNum, allProblemNum);
            String threePercent = pointsCalculate.caculateToPercent(threeNum, allProblemNum);
            String fourPercent = pointsCalculate.caculateToPercent(fourNum, allProblemNum);
            String txAndOnePercent = pointsCalculate.caculateToPercent(txNum + oneNum, allProblemNum);
            dataMap.put("txPercent", txPercent);
            dataMap.put("onePercent", onePercent);
            dataMap.put("twoPercent", twoPercent);
            dataMap.put("threePercent", threePercent);
            dataMap.put("fourPercent", fourPercent);
            DefaultPieDataset datasetRiskPie = new DefaultPieDataset();
            DefaultCategoryDataset datasetRiskBar = new DefaultCategoryDataset();
            datasetRiskPie.setValue("提醒和特征值1" + ":" + txAndOnePercent, new Double(txNum + oneNum));
            datasetRiskPie.setValue("特征值2" + ":" + twoPercent, new Double(twoNum));
            datasetRiskPie.setValue("特征值3" + ":" + threePercent, new Double(threeNum));
            datasetRiskPie.setValue("特征值4" + ":" + fourPercent, new Double(fourNum));
            final String flag1 = "提醒和特征值1";
            final String flag2 = "特征值2";
            final String flag3 = "特征值3";
            final String flag4 = "特征值4";
            final String riskBar = "特征值情况统计";
            datasetRiskBar.addValue(txNum + oneNum, flag1, riskBar);
            datasetRiskBar.addValue(twoNum, flag2, riskBar);
            datasetRiskBar.addValue(threeNum, flag3, riskBar);
            datasetRiskBar.addValue(fourNum, flag4, riskBar);
            try {
                JFreeChart chart = ChartFactory.createPieChart("隐患分布饼图", datasetRiskPie, true, true, false);
                final PiePlot plot = (PiePlot) chart.getPlot();
                plot.setStartAngle(0);
                plot.setForegroundAlpha(0.90f);
                plot.setInteriorGap(0.02);
                chart.getLegend().setVisible(false);
                plot.setSectionPaint("特征值1" + ":" + txAndOnePercent, new Color(49, 95, 232));
                plot.setSectionPaint("特征值2" + ":" + twoPercent, new Color(232, 232, 49));
                plot.setSectionPaint("特征值3" + ":" + threePercent, new Color(240, 117, 60));
                plot.setSectionPaint("特征值4" + ":" + fourPercent, new Color(232, 36, 18));

                File pieChart = new File(IMG_PATH + fileName + "RiskpieChart.png");
                ChartUtils.saveChartAsPNG(pieChart, chart, width, height);
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                JFreeChart barChart = ChartFactory.createBarChart("隐患分布直方图",
                        "",
                        "数量",
                        datasetRiskBar,
                        PlotOrientation.VERTICAL,
                        true, true, false);
                CategoryPlot plot = (CategoryPlot) barChart.getPlot();
                plot.getRenderer().setSeriesPaint(0, new Color(49, 95, 232));
                plot.getRenderer().setSeriesPaint(1, new Color(232, 232, 49));
                plot.getRenderer().setSeriesPaint(2, new Color(240, 117, 60));
                plot.getRenderer().setSeriesPaint(3, new Color(232, 36, 18));
                BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
                barRenderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
                barRenderer.setDefaultItemLabelsVisible(true);
                barRenderer.setItemLabelAnchorOffset(-20D);
                //File barChartFile = new File("C:\\Users\\96500\\Desktop\\test\\" + fileName + "RiskbarChart.png");
                File barChartFile = new File(IMG_PATH + fileName + "RiskbarChart.png");
                ChartUtils.saveChartAsPNG(barChartFile, barChart, width, height);

            } catch (Exception e) {
                e.printStackTrace();
            }
            String RiskpieChartImgPath=IMG_PATH + fileName + "RiskpieChart.png";
            String RiskbarChartImgPath=IMG_PATH + fileName + "RiskbarChart.png";
            dataMap.put("pic8", MDoc.getImageStr(RiskpieChartImgPath));
            dataMap.put("pic9", MDoc.getImageStr(RiskbarChartImgPath));


        }


        //第二部分，各部分工程检查情况
        String section2pName1 = "";
        List<Object> section2List = new ArrayList<Object>();
        for (int b = 0; b < name1Array.size(); b++) {
            Map<String, Object> section2Name1Map = new HashMap<String, Object>();
            List<Object> section2name1List = new ArrayList<Object>();
            String section2name1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(b));
            if (section2name1.equals("安全检查")) {
                section2pName1 = "安全问题";
            } else if (section2name1.equals("质量检查")) {
                section2pName1 = "质量问题";
            } else if (section2name1.equals("管理行为")) {
                section2pName1 = "管理体系及管理动作";
            }
            section2Name1Map.put("section2pName1", section2pName1);
            List<Object> section2Name4Info = problemCollectDetailMapper.getAllName4ByName1(checkId, section2name1);
            String section2Name44 = JSON.toJSONString(section2Name4Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray section2Name4Array = JSONArray.parseArray(section2Name44);
            for (int w = 0; w < section2Name4Array.size(); w++) {
                Map<String, Object> section2Name4Map = new HashMap<String, Object>();
                List<Object> section2Name4List = new ArrayList<Object>();
                int section2Name4Id = section2Name4Array.getIntValue(w);
                String section2Name4 = prefixsystemMapper.getName4ByName4Id(section2Name4Id);
                List<ProblemCollectDetail> section2Name6Info = problemCollectDetailMapper.getAllName6InfoByName4(checkId, section2Name4Id, section2name1);
                String section2Name66 = JSON.toJSONString(section2Name6Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray section2Name6Array = JSONArray.parseArray(section2Name66);
                for (int c = 0; c < section2Name6Array.size(); c++) {
                    Map<String, Object> section2Name6Map = new HashMap<String, Object>();
                    List<Object> picList = new ArrayList<Object>();
                    JSONObject section2Name6Object = section2Name6Array.getJSONObject(c);
                    section2Name6Map.put("section2pName6No", c + 1);
                    section2Name6Map.put("section2pName6", section2Name6Object.getString("pName6"));
                    section2Name6Map.put("section2pName5", section2Name6Object.getString("pName5"));
                    section2Name6Map.put("section2RiskLevel", section2Name6Object.getString("riskPoint"));
                    section2Name6Map.put("section2CheckPart", section2Name6Object.getString("checkPart"));
                    section2Name6Map.put("section2ProblemNum", section2Name6Object.getString("problemQua"));
                    if (section2Name6Object.getString("isRemark").equals("N")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("problemDescription"));
                    } else if (section2Name6Object.getString("isRemark").equals("Y")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("remark"));
                    }
                    section2Name6Map.put("section2normsProvison", section2Name6Object.getString("normsProvison"));
                    section2Name6Map.put("section2suggestion", section2Name6Object.getString("suggestion"));
                    String section2picPath = section2Name6Object.getString("picPath");
                    String picName = section2Name6Object.getString("picName");
                    JSONArray ja = JSONArray.parseArray(picName);
                    if (ja.size() == 0) {
//                        String s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                        String imgPath = IMG_PATH+ "noPic.png";
                        if(!MDoc.isFoundImageStr(imgPath)){
                            imgPath=TEST_IMG_PATH;
                        }
                        String s = MDoc.getImageStr(imgPath);
                        picList.add(s);
                    } else {
                        for (int o = 0; o < ja.size(); o++) {
                            String s="";
                            if("prod".equals(profiles.getActives())){
                                s = MDoc.getImageStr(section2picPath + ja.getString(o));
                            }
                            //String s = MDoc.getImageStr(section2picPath + ja.getString(o));
//                            String s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                            picList.add(s);
                        }
                    }
                    section2Name6Map.put("picList", picList);
                    section2Name4List.add(section2Name6Map);

                }
                section2Name4Map.put("section2pName4", section2Name4);
                section2Name4Map.put("section2Name4List", section2Name4List);
                section2name1List.add(section2Name4Map);
            }
            section2Name1Map.put("section2Name1List", section2name1List);
            section2List.add(section2Name1Map);
        }
        String pieChartImgPath="";
        String barChartImgPath= "";
        try {
            JFreeChart chart = ChartFactory.createPieChart("现场施工问题分布饼图", datasetPie, true, true, false);
            final PiePlot plot = (PiePlot) chart.getPlot();
            plot.setStartAngle(270);
            plot.setForegroundAlpha(0.90f);
            plot.setInteriorGap(0.02);
            chart.getLegend().setVisible(false);
            //File pieChart = new File("C:\\Users\\96500\\Desktop\\test\\" + fileName + "pieChart.png");
            pieChartImgPath =IMG_PATH + fileName + "pieChart.png";
            File pieChart = new File(pieChartImgPath);
//            File pieChart = new File("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "pieChart.png");
            ChartUtils.saveChartAsPNG(pieChart, chart, width, height);
        } catch (Exception e) {
            e.printStackTrace();
        }

        try {
            JFreeChart barChart = ChartFactory.createBarChart("现场施工问题分布直方图",
                    "",
                    "数量",
                    datasetBar,
                    PlotOrientation.VERTICAL,
                    true, true, false);
            CategoryPlot plot = (CategoryPlot) barChart.getPlot();
            plot.getRenderer().setSeriesPaint(0, new Color(5, 87, 232));
            BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
            barRenderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
            barRenderer.setDefaultItemLabelsVisible(true);
            barRenderer.setItemLabelAnchorOffset(-20D);
            barRenderer.setMaximumBarWidth(0.2);
            CategoryAxis categoryAxis = plot.getDomainAxis();
            categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
            //File barChartFile = new File("C:\\Users\\96500\\Desktop\\test\\" + fileName + "barChart.png");
            barChartImgPath =IMG_PATH + fileName + "barChart.png";
            File barChartFile = new File(barChartImgPath);
//            File barChartFile = new File("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "barChart.png");

            ChartUtils.saveChartAsPNG(barChartFile, barChart, width, height);
        } catch (Exception e) {
            e.printStackTrace();
        }
        //dataMap.put("pic6", MDoc.getImageStr("C:\\Users\\96500\\Desktop\\test\\" + fileName + "pieChart.png"));
        //dataMap.put("pic7", MDoc.getImageStr("C:\\Users\\96500\\Desktop\\test\\" + fileName + "barChart.png"));

        dataMap.put("pic6", MDoc.getImageStr(pieChartImgPath));
        dataMap.put("pic7", MDoc.getImageStr(barChartImgPath));
//        dataMap.put("pic6", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "pieChart.png"));
//        dataMap.put("pic7", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "barChart.png"));
        dataMap.put("section2List", section2List);
        MDoc mdoc = new MDoc();
      /*  if (reportType == 1) {
            mdoc.createDoc(dataMap, "C:\\Users\\96500\\Desktop\\test\\" + fileName + ".doc", "ftl\\5.0.ftl");
            MDoc.docToDocx("C:\\Users\\96500\\Desktop\\test\\" + fileName + ".doc", "C:\\Users\\96500\\Desktop\\test\\" + fileName + ".doc");
        } else if (reportType == 2) {
            mdoc.createDoc(dataMap, "C:\\Users\\96500\\Desktop\\Risktest\\" + fileName + ".doc", "ftl\\Risk2.0.ftl");
            MDoc.docToDocx("C:\\Users\\96500\\Desktop\\Risktest\\" + fileName + ".doc", "C:\\Users\\96500\\Desktop\\Risktest\\" + fileName + ".doc");
        }
        return "success";*/
        String path = FileUtil.getServerFolderPath();
        System.out.println(path);
        File f1 = new File(path, "doc");
        if (!f1.exists()) {
            f1.mkdirs();
        }
        String result="";
        if (reportType == 1) {
            System.out.println(urlProperties.getAddress());
//            mdoc.createDoc(dataMap, "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc", "ftl\\5.0.ftl");
//            MDoc.docToDocx("E:\\tencent_File\\1296928795\\FileRecv\\yirui" + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc", "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc");
//            result = "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc";
            String reportName=projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc";
            String pathStr=path +"\\doc\\" + reportName;
            mdoc.createDoc(dataMap, pathStr, "ftl\\5.0.ftl");
            //MDoc.docToDocx("D:\\doc\\" + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc", "D:\\doc\\" + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc");
            String url=urlProperties.getAddress()+"\\doc\\";
            result=url  + reportName;

//           mdoc.createDoc(dataMap, "D:\\WAAA\\新建文件夹\\"  + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc", "ftl\\5.0.ftl");
//           MDoc.docToDocx("D:\\WAAA\\新建文件夹\\" + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".d测试服务器迁移的进展oc", "D:\\WAAA\\新建文件夹\\" + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc");
//           result="D:\\WAAA\\新建文件夹"  + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc";


        } else if (reportType == 2) {
//            mdoc.createDoc(dataMap, "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc", "ftl\\Risk2.0.ftl");
//            MDoc.docToDocx("E:\\tencent_File\\1296928795\\FileRecv\\yirui" + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc", "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc");
//            result = "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc";
            mdoc.createDoc(dataMap, path + "\\doc\\" + projectObject.getString("projectName").replace('#','号')+"隐患报告"+fileName + ".doc", "ftl\\Risk2.0.ftl");
            //MDoc.docToDocx("D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + projectObject.getString("projectName").replace('#','号')+"隐患报告"+fileName + ".doc", "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\"+ projectObject.getString("projectName").replace('#','号')+"隐患报告"+fileName +".doc");
            result=urlProperties.getAddress()+"/doc/"  + projectObject.getString("projectName").replace('#','号')+"隐患报告"+fileName + ".doc";

//           mdoc.createDoc(dataMap, "D:\\WAAA\\新建文件夹" + "\\" + projectObject.getString("projectName").replace('#','号')+"隐患报告"+fileName + ".doc", "ftl\\Risk2.0.ftl");
//           MDoc.docToDocx("D:\\\\WAAA\\\\新建文件夹\\" + projectObject.getString("projectName").replace('#','号')+"隐患报告"+fileName + ".doc", "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\"+ projectObject.getString("projectName").replace('#','号')+"隐患报告"+fileName +".doc");
        }
        return result;
    }

    private double calculateAllWeight4Func(int checkId, JSONObject part2InnerObject) {
        double allweight4 = 0;
        Integer taskId = contractchecktaskMapper.getTaskIdByCheckId(checkId);
        List<ProblemCollectDetail> countFourthWeight=problemCollectDetailMapper.getAllFourthInfoMXTQ(checkId,part2InnerObject.getIntValue("thirdId"));
        for (int v = 0; v < countFourthWeight.size(); v++) {
            double Tweight4 = 0;
            int fourthId =countFourthWeight.get(v).getFourthId();
//            String trueweight4 = prefixsystemMapper.getWeight3ByThirdId(fourthId);
//            Tweight4 = pointsCalculate.getPercentInstance(trueweight4);

            String newWeight4 = editableweightpsMapper.getWeightByNumber(fourthId, taskId);
            if (StringUtils.isNotBlank(newWeight4)){
                Tweight4 = pointsCalculate.getPercentInstance(newWeight4);
            }else{
                String trueweight4 = prefixsystemMapper.getWeight3ByThirdId(fourthId);
                Tweight4 = pointsCalculate.getPercentInstance(trueweight4);
            }

            allweight4 += Tweight4;
        }
        return allweight4;
    }

    private String getCheckItemPointAndUpdateAllPointSave(int checkId, int part2FourthId, int projectId, double checkItemPoint, DecimalFormat df) {
        List<ProblemCollectDetail> checkItemCalcuList = problemCollectDetailMapper.getAllFourthInfo(checkId, part2FourthId);
        String maxFourthRiskPoint = pointsCalculate.getMaxRiskPoint(checkItemCalcuList);
        int maxFourthRiskPointNum = problemCollectDetailMapper.getRiskPointCount(checkId, part2FourthId, maxFourthRiskPoint);
        double limitFourhPoint = Double.parseDouble((pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint)) == null ? "100" : pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint));
        if (checkItemPoint > limitFourhPoint) {
            checkItemPoint = limitFourhPoint;
        }
        String s = df.format(checkItemPoint);
        int allPointSaveFourthPointCount = allpointsaveMapper.getAllPointCountByCheckId(checkId, part2FourthId);
        if (allPointSaveFourthPointCount != 0) {
            SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
            Date date1 = new Date(System.currentTimeMillis());
            String lastEditTime=formatter.format(date1);
            allpointsaveMapper.updateAllPoint(checkId, s, part2FourthId,lastEditTime);
        } else {
            Allpointsave allpointsave = new Allpointsave();
            SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
            Date date1 = new Date(System.currentTimeMillis());
            allpointsave.setNewCreateTime(formatter.format(date1));
            allpointsave.setLastEditTime(formatter.format(date1));
            allpointsave.setProjectId(projectId);
            allpointsave.setCheckId(checkId);
            allpointsave.setNumber(part2FourthId);
            allpointsave.setPoint(s);
            allpointsaveMapper.insert(allpointsave);
        }
        return s;
    }

    private double calculateNoProblemPointFunc(int checkId, JSONObject part2InnerObject) {
        double noProblemPoint = 0;
        List<Object> noProblemSixthIdList = uncheckeditemsMapper.getNoProblemSixthId(checkId, part2InnerObject.getIntValue("fourthId"));
        String noProblemSixthIdInfo = JSON.toJSONString(noProblemSixthIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray noProblemSixthArray = JSONArray.parseArray(noProblemSixthIdInfo);
        for (int m = 0; m < noProblemSixthArray.size(); m++) {
            int noProblemSixthId = noProblemSixthArray.getIntValue(m);
            double noProblem = Double.parseDouble(prefixsystemMapper.getPoint4ByPoint4Id(noProblemSixthId));
            noProblemPoint += noProblem;
        }
        return noProblemPoint;
    }

    public String getPart2InnerListweight4 (int checkId, int part2ThirdId, double weight3, double weight4, double allweight4){
        //int countFourthId=prefixsystemMapper.getCountFourth(part2ThirdId);
        List<Object> fourthCountList = problemCollectDetailMapper.getFourthCountList(checkId, part2ThirdId);
        String fourthCountInfo = JSON.toJSONString(fourthCountList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray fourthCountInfoArray = JSONArray.parseArray(fourthCountInfo);
        int countFourthId = fourthCountInfoArray.size();
        return pointsCalculate.double2ToPercent(weight3, allweight4/weight4);
    }

    public List<Double> calculatePoint6Func(JSONArray sixthPointsArray, int checkId){
        double calculatePoint66 = 0;
        double calculatePoint6 = 0;
        double calculateTruePoint = 0;
        for (int y = 0; y < sixthPointsArray.size(); y++) {
            JSONObject sixPointObject = sixthPointsArray.getJSONObject(y);
            int deductSixthId = sixPointObject.getIntValue("sixthId");
            System.out.println("sixId:"+deductSixthId);
            float deductPointsSumFloat = problemCollectDetailMapper.getdeductSum(checkId, deductSixthId);
            double deductPointsSum = Double.valueOf(String.valueOf(deductPointsSumFloat));
            double truePoint = Double.parseDouble(sixPointObject.getString("point6"));
            System.out.println("各类point:"+deductPointsSum+" "+truePoint);
            if (truePoint <= deductPointsSum) {
                calculatePoint66 = 0;
            } else {
                calculatePoint66 = truePoint - deductPointsSum;
            }
            calculateTruePoint += truePoint;  //体系分数
            calculatePoint6 += calculatePoint66;  //得分总和
        }
        List<Double> calculatePointList = new ArrayList<>();
        calculatePointList.add(calculateTruePoint);
        calculatePointList.add(calculatePoint6);
        System.out.println("计算point6:"+calculatePointList);
        return calculatePointList;
    }

    /**
     * 要改的  中建三局质量报告模板
     * @param projectId
     * @param checkId
     * @return
     * @throws UnsupportedEncodingException
     */
    @Override
    public String generateReportType4(int projectId, int checkId) throws UnsupportedEncodingException {
        //格式化十进制的类，此处为保留两位小数
        DecimalFormat df = new DecimalFormat("0.00");
        double scAllPoint = 0;
        Integer taskId = contractchecktaskMapper.getTaskIdByCheckId(checkId);
        //总的数据结构datamap
        Map<String, Object> dataMap = new HashMap<String, Object>();
        //生成报告的时间
        Date date = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        DateFormat d2 = new SimpleDateFormat("yyyy");
        DateFormat d3 = new SimpleDateFormat("MM");
        DateFormat d4 = new SimpleDateFormat("dd");
        String day = d4.format(date);
        String month = d3.format(date);
        String year = d2.format(date);
        String fileName = d1.format(date);
        dataMap.put("day", day);
        dataMap.put("month", month);
        dataMap.put("year", year);

        //第一部分 --------- 一、工程概况部分，来自ctp的工程信息
        //根据projectId拿到工程信息。其实就一条数据，存在了list里。
        List<ContractTaskProject> projectList = contracttaskprojectMapper.selectAllByCheckId(projectId);
        //fastJson工具类。WriteMapNullValue输出值为null的字段；DisableCircularReferenceDetect消除对同一对象循环引用的问题
        String project = JSON.toJSONString(projectList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        //fastJson工具类。json数组
        JSONArray projectArray = JSONArray.parseArray(project);
        JSONObject projectObject = projectArray.getJSONObject(0);
        dataMap.put("projectName", projectObject.getString("projectName"));
        dataMap.put("projectAddress", projectObject.getString("area"));
        dataMap.put("jsUnit", projectObject.getString("jsUnit"));
        dataMap.put("jlUnit", projectObject.getString("jlUnit"));
        dataMap.put("sgUnit", projectObject.getString("sgUnit"));
        dataMap.put("projectType", projectObject.getString("projectType"));
        dataMap.put("remark", projectObject.getString("remark"));
        dataMap.put("projectDescription", projectObject.getString("projectDescription"));
        String js = projectObject.getString("jsUniter");
        String jl = projectObject.getString("jlUniter");
        String sg = projectObject.getString("manager");
        dataMap.put("jsUniter", js);
        dataMap.put("jlUniter", jl);
        dataMap.put("sgUniter", sg);

        //第一部分 --------- 二、评估结果 -------（一）综合评估结果
        //质量风险计算部分，有乘权重
        //628number代表体系里的第一级的质量检查，因为是质量报告
        String ZJname1 = "[628]";
        double allsecondPoint = 0;
        JSONArray ZJname1Array = JSONArray.parseArray(ZJname1);
        //根据checkId求总的extraReduce，并转为double
        float allExtraPointFloat = problemCollectDetailMapper.getAllExtraPoint(checkId);
        double allExtraPoint = Double.valueOf(String.valueOf(allExtraPointFloat));

        double overAllPoint = 0;

        //第一级所有权重和，这里也就是质量检查的权重
        double allweight1 = 0;
        //只有一个质量检查
        for (int i = 0; i < ZJname1Array.size(); i++) {
            double Tweight1 = 0;
            //根据628number拿到质量检查的权重。
            String weight1 = prefixsystemMapper.getWeight1ByName1(prefixsystemMapper.getName4ByName4Id(ZJname1Array.getIntValue(i)));
            //权重String转为double
            Tweight1 = pointsCalculate.getPercentInstance(weight1);
            allweight1 += Tweight1;
        }

        for (int k = 0; k < ZJname1Array.size(); k++) {
            //质量检查
            String pName1 = prefixsystemMapper.getName4ByName4Id(ZJname1Array.getIntValue(k));
            //和上面一样，拿质量检查的权重double
            double Tweight1 = 0;
            String weight1 = prefixsystemMapper.getWeight1ByName1(pName1);
            Tweight1 = pointsCalculate.getPercentInstance(weight1);

            //根据checkId和质量检查拿到第二级的number列表，结果同checkId和628=preNum2
            List<Object> secondIdList = problemCollectDetailMapper.getSecondId(checkId, pName1);
            //list转json数组
            String secondIdInfo = JSON.toJSONString(secondIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray secondIdInfoArray = JSONArray.parseArray(secondIdInfo);

            //求质量检查下的第二级权重和。要不要更改？
            double allweight2 = 0;
            for (int p = 0; p < secondIdInfoArray.size(); p++) {
                int allsecondId = secondIdInfoArray.getIntValue(p);
                String weight2 = prefixsystemMapper.getWeight3ByThirdId(allsecondId);
                double weight22 = pointsCalculate.getPercentInstance(weight2);
                allweight2 += weight22;
            }

            //2、4、6遍历
            for (int u = 0; u < secondIdInfoArray.size(); u++) {
                int secondId = secondIdInfoArray.getIntValue(u);

                //第二级每一项的权重。二级的权重，这里要不要更改？？？
                double weight222 = 0;
                String weight2 = prefixsystemMapper.getWeight3ByThirdId(secondId);
                weight222 = pointsCalculate.getPercentInstance(weight2);

                //取第四级的ProblemCollectDetail列表，并转为数组，之后遍历。根据fourthId去重
                //测试“checkId:41;secondId:629
                List<ProblemCollectDetail> fourthPoints = problemCollectDetailMapper.getFourthPoint(checkId, pName1, secondId);
                String fourthCalculateInfo = JSON.toJSONString(fourthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray fourthPointsCalculateArray = JSONArray.parseArray(fourthCalculateInfo);

                double point = 0;
                double point11=0;
                for (int j = 0; j < fourthPointsCalculateArray.size(); j++) {
                    Map<String, Object> part2InnerMap = new HashMap<String, Object>();
                    JSONObject part2InnerObject = fourthPointsCalculateArray.getJSONObject(j);
                    part2InnerMap.put("pName4", part2InnerObject.getString("pName4"));

                    //没用的一段代码
                    double weight3 = 0;
                    int part2FourthId = part2InnerObject.getIntValue("fourthId");
                    int part2InnerProblemNum = problemCollectDetailMapper.getProblemNumByFourthId(checkId, part2FourthId);
                    int part2ThirdId = part2InnerObject.getIntValue("thirdId");
 //                   weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
                    String newWeight33 = editableweightpsMapper.getWeightByNumber(part2ThirdId,taskId);
                    if(StringUtils.isNotBlank(newWeight33)){
                        weight3 = pointsCalculate.getPercentInstance(newWeight33);
                    }else {
                        weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
                    }

                    //没用的一段代码。拿到第四级的number，并转为数组
                    List<Object> fourthCountList = problemCollectDetailMapper.getFourthCountList(checkId, part2ThirdId);
                    String fourthCountInfo = JSON.toJSONString(fourthCountList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray fourthCountInfoArray = JSONArray.parseArray(fourthCountInfo);
                    int countFourthId = fourthCountInfoArray.size();

                    //以下代码都是为了算checkItemPoint，thirdPoint是总的
                    //取第四级的ProblemCollectDetail列表，并转为数组，之后遍历。根据sixthId去重
                    List<ProblemCollectDetail> sixthPoints = problemCollectDetailMapper.getsixthPoints(checkId, part2FourthId);
                    String pointName6Info = JSON.toJSONString(sixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray sixthPointsArray = JSONArray.parseArray(pointName6Info);

                    //减过分
                    double calculatePoint6 = 0;
                    //暂存每次循环计算的分
                    double calculatePoint66 = 0;
                    //不减分
                    double calculateTruePoint = 0;
                    //遍历。为什么叫sixpoint，由第四级number取到的
                    for (int y = 0; y < sixthPointsArray.size(); y++) {
                        JSONObject sixPointObject = sixthPointsArray.getJSONObject(y);

                        //由第六级number拿到reducepoint的总分。reducepoint到底是个什么分
                        int deductSixthId = sixPointObject.getIntValue("sixthId");
                        float deductPointsSumFloat = problemCollectDetailMapper.getdeductSum(checkId, deductSixthId);
                        double deductPointsSum = Double.valueOf(String.valueOf(deductPointsSumFloat));

                        //6级的分
                        double truePoint = Double.parseDouble(sixPointObject.getString("point6"));
                        //calculatePoint66：6级的分减去reducepoint。为什么是减的总分
                        if (truePoint <= deductPointsSum) {
                            calculatePoint66 = 0;
                        } else {
                            calculatePoint66 = truePoint - deductPointsSum;
                        }
                        calculateTruePoint += truePoint;
                        calculatePoint6 += calculatePoint66;
                    }

                    //无问题项的分。怎么确定的无问题项？这里直接拿的第六级
                    double noProblemPoint = 0;
                    //uncheckedItems是干啥的？无问题项。根据4级id拿6级id。为什么不直接遍历？非要换成jsonarray
                    List<Object> noProblemSixthIdList = uncheckeditemsMapper.getNoProblemSixthId(checkId, part2InnerObject.getIntValue("fourthId"));
                    String noProblemSixthIdInfo = JSON.toJSONString(noProblemSixthIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray noProblemSixthArray = JSONArray.parseArray(noProblemSixthIdInfo);
                    for (int m = 0; m < noProblemSixthArray.size(); m++) {
                        int noProblemSixthId = noProblemSixthArray.getIntValue(m);
                        double noProblem = Double.parseDouble(prefixsystemMapper.getPoint4ByPoint4Id(noProblemSixthId));
                        noProblemPoint += noProblem;
                    }

                    //checkItemPoint
                    double checkItemPoint = (calculatePoint6 + noProblemPoint) / (calculateTruePoint + noProblemPoint) * 100;

                    //limitFourhPoint是什么？？？
                    //拿最大风险等级？根据4级id
                    List<ProblemCollectDetail> checkItemCalcuList = problemCollectDetailMapper.getAllFourthInfo(checkId, part2FourthId);
                    String maxFourthRiskPoint = pointsCalculate.getMaxRiskPoint(checkItemCalcuList);
                    //最大风险等级的数据数量
                    int maxFourthRiskPointNum = problemCollectDetailMapper.getRiskPointCount(checkId, part2FourthId, maxFourthRiskPoint);
                    //limitPoint是干啥的？打分？
                    double limitFourhPoint = Double.parseDouble((pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint)) == null ? "100" : pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint));

                    //处理checkItemPoint
                    if (checkItemPoint > limitFourhPoint) {
                        checkItemPoint = limitFourhPoint;
                    }
                    //两位小数，string
                    String s = df.format(checkItemPoint);
                    part2InnerMap.put("checkItemPoint", s);

                    //allpointsave是用来干嘛的？计算完分后，存一下
                    //number为-1时，存的总分。
                    int allPointSaveFourthPointCount = allpointsaveMapper.getAllPointCountByCheckId(checkId, part2FourthId);
                    if (allPointSaveFourthPointCount != 0) {
                        SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                        Date date1 = new Date(System.currentTimeMillis());
                        String lastEditTime=formatter.format(date1);
                        allpointsaveMapper.updateAllPoint(checkId, s, part2FourthId,lastEditTime);
                    } else {
                        Allpointsave allpointsave = new Allpointsave();
                        SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                        Date date1 = new Date(System.currentTimeMillis());
                        allpointsave.setNewCreateTime(formatter.format(date1));
                        allpointsave.setLastEditTime(formatter.format(date1));
                        allpointsave.setProjectId(projectId);
                        allpointsave.setCheckId(checkId);
                        allpointsave.setNumber(part2FourthId);
                        allpointsave.setPoint(s);
                        allpointsaveMapper.insert(allpointsave);
                    }

                    //干啥的？四级的分？thirdPoint？secondPoint？
                    point += calculatePoint6 + noProblemPoint;
                    point11+=calculateTruePoint + noProblemPoint;
                }
                //分*权重，满分100分，权重归一
                double thirdPoint = Double.parseDouble(df.format(point /point11*100));
                double percent2 = Double.parseDouble(df.format(weight222 / allweight2));
                double secondPoint = Double.parseDouble(df.format(thirdPoint * percent2));
                //用于计算质量风险的
                allsecondPoint += secondPoint;
            }

            //更新了一些表
            //1级
            int firstPointCount = allpointsaveMapper.getAllPointCountByCheckId(checkId, 1);
            if (firstPointCount != 0) {
                SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                Date date1 = new Date(System.currentTimeMillis());
                String lastEditTime=formatter.format(date1);
                allpointsaveMapper.updateAllPoint(checkId, df.format(allsecondPoint), 1,lastEditTime);
            } else {
                Allpointsave allpointsave = new Allpointsave();
                allpointsave.setCheckId(checkId);
                allpointsave.setNumber(1);
                allpointsave.setPoint(df.format(allsecondPoint));
                allpointsave.setProjectId(projectId);
                allpointsaveMapper.insert(allpointsave);
            }
            //算权重
            double trueWeight1 = Double.parseDouble(df.format(Tweight1 / allweight1));
            float allExtra = problemCollectDetailMapper.getAllExtraPoint(checkId);
            double allExtraPoints = Double.valueOf(String.valueOf(allExtra));
            overAllPoint += Double.parseDouble(df.format(trueWeight1 * allsecondPoint-allExtraPoints));
        }

        //设置工程的LatestRiskLevel，是什么？
        List<ProblemCollectDetail> overallList = problemCollectDetailMapper.getAllProblemCollectInfoByCheckId(checkId);
        ContractTaskProject contractTaskProjectRiskPoint = new ContractTaskProject();
        SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
        Date date1 = new Date(System.currentTimeMillis());
        contractTaskProjectRiskPoint.setLastEditTime(formatter.format(date1));
        contractTaskProjectRiskPoint.setProjectId(projectId);
        contractTaskProjectRiskPoint.setLatestRiskLevel(pointsCalculate.getMaxRiskPoint(overallList));
        contracttaskprojectMapper.updateByPrimaryKeySelective(contractTaskProjectRiskPoint);

        //设置工程的LatestCheckTime
        ContractTaskProject newRiskList = contracttaskprojectMapper.selectByPrimaryKey(projectId);
        String finishTime = contractchecktaskMapper.getFinishTimeByCheckId(checkId);
        if (newRiskList.getCheckTime().equals("") || newRiskList.getCheckTime().compareTo(finishTime) <= 0) {
            try {
                ContractTaskProject contracttaskproject = new ContractTaskProject();
                SimpleDateFormat formatter1= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                Date date2 = new Date(System.currentTimeMillis());
                contracttaskproject.setLastEditTime(formatter1.format(date2));
                contracttaskproject.setProjectId(projectId);
                contracttaskproject.setLatestCheckTime(finishTime);
                contracttaskprojectMapper.updateByPrimaryKeySelective(contracttaskproject);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        //2879是管理行为下的中建三局绿色公司(质量）。拿3级id
        List<Integer> ZJThirdIdList = problemCollectDetailMapper.getAllZJthirdId(checkId, 2879);
        List<Object> ZJList = new ArrayList<Object>();
        for (int t = 0; t < ZJThirdIdList.size(); t++) {
            Map<String, Object> ZJMap = new HashMap<String, Object>();
            String ZJtype = "";
            double ZJallOverPoint = 0;
            double ZJthirdPoint = 0;
            //怎么算的？逻辑
            //实测实量，0
            ZJMap.put("scAllPoint", scAllPoint);
            //管理行为计算在下面
            ZJMap.put("thirdPoint", "\\");
            //序号
            ZJMap.put("No", t + 1);
            //质量风险
            ZJMap.put("zlAllPoint", allsecondPoint-allExtraPoint);
            //评估对象
            ZJMap.put("pName3", prefixsystemMapper.getName4ByName4Id(ZJThirdIdList.get(t)));
            //评估类型
            switch (prefixsystemMapper.getName4ByName4Id(ZJThirdIdList.get(t))) {
                case "投资项目":
                    ZJtype = "投资管理";
                    break;
                case "监理":
                    ZJtype = "投资管理";
                    break;
                case "EPC(联营)":
                    ZJtype = "EPC";
                    break;
                case "EPC(自营)":
                    ZJtype = "EPC";
                    break;
                case "PC工厂":
                    ZJtype = "PC生产管理";
                    break;
                default:
                    ZJtype = "";
                    break;
            }
            //根据第三级id拿到对象数组，即第四级？
            List<ProblemCollectDetail> ZJfourthPoints = problemCollectDetailMapper.getZJFourthPoint(checkId, ZJThirdIdList.get(t));
            String ZJfourthCalculateInfo = JSON.toJSONString(ZJfourthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray ZJfourthPointsCalculateArray = JSONArray.parseArray(ZJfourthCalculateInfo);

            //减
            double point1=0;
            //没减
            double point2=0;
            for (int j = 0; j < ZJfourthPointsCalculateArray.size(); j++) {
                JSONObject ZJpart2InnerObject = ZJfourthPointsCalculateArray.getJSONObject(j);

                //groupby six为什么就是sixpoint
                int ZJpart2FourthId = ZJpart2InnerObject.getIntValue("fourthId");
                List<ProblemCollectDetail> ZJsixthPoints = problemCollectDetailMapper.getZJsixthPoints(checkId, ZJpart2FourthId);
                String ZJpointName6Info = JSON.toJSONString(ZJsixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray ZJsixthPointsArray = JSONArray.parseArray(ZJpointName6Info);

                //和上面一样的逻辑，算分
                double ZJcalculatePoint6 = 0;
                double ZJcalculatePoint66 = 0;
                double ZJcalculateTruePoint = 0;
                for (int y = 0; y < ZJsixthPointsArray.size(); y++) {
                    JSONObject ZJsixPointObject = ZJsixthPointsArray.getJSONObject(y);
                    int ZJdeductSixthId = ZJsixPointObject.getIntValue("sixthId");
                    float ZJdeductPointsSumFloat = problemCollectDetailMapper.getdeductSum(checkId, ZJdeductSixthId);
                    double ZJdeductPointsSum = Double.valueOf(String.valueOf(ZJdeductPointsSumFloat));
                    double ZJtruePoint = Double.parseDouble(ZJsixPointObject.getString("point6"));
                    if (ZJtruePoint <= ZJdeductPointsSum) {
                        ZJcalculatePoint66 = 0;
                    } else {
                        ZJcalculatePoint66 = ZJtruePoint - ZJdeductPointsSum;
                    }
                    ZJcalculateTruePoint += ZJtruePoint;
                    ZJcalculatePoint6 += ZJcalculatePoint66;
                }

                //管理行为无问题项的分
                double ZJnoProblemPoint = 0;
                List<Object> ZJnoProblemSixthIdList = uncheckeditemsMapper.getNoProblemSixthId(checkId, ZJpart2FourthId);
                String ZJnoProblemSixthIdInfo = JSON.toJSONString(ZJnoProblemSixthIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray ZJnoProblemSixthArray = JSONArray.parseArray(ZJnoProblemSixthIdInfo);
                for (int m = 0; m < ZJnoProblemSixthArray.size(); m++) {
                    int ZJnoProblemSixthId = ZJnoProblemSixthArray.getIntValue(m);
                    double ZJnoProblem = Double.parseDouble(prefixsystemMapper.getPoint4ByPoint4Id(ZJnoProblemSixthId));
                    ZJnoProblemPoint += ZJnoProblem;
                }

                //ZJcheckItemPoint
                double ZJcheckItemPoint = (ZJcalculatePoint6 + ZJnoProblemPoint) / (ZJcalculateTruePoint + ZJnoProblemPoint) * 100;
                List<ProblemCollectDetail> ZJcheckItemCalcuList = problemCollectDetailMapper.getAllFourthInfo(checkId, ZJpart2FourthId);
                String ZJmaxFourthRiskPoint = pointsCalculate.getMaxRiskPoint(ZJcheckItemCalcuList);
                int ZJmaxFourthRiskPointNum = problemCollectDetailMapper.getRiskPointCount(checkId, ZJpart2FourthId, ZJmaxFourthRiskPoint);
                double ZJlimitFourthPoint = Double.parseDouble((pointlimitMapper.getLimitPointByInfo(String.valueOf(ZJmaxFourthRiskPointNum), ZJmaxFourthRiskPoint)) == null ? "100" : pointlimitMapper.getLimitPointByInfo(String.valueOf(ZJmaxFourthRiskPointNum), ZJmaxFourthRiskPoint));
                if (ZJcheckItemPoint > ZJlimitFourthPoint) {
                    ZJcheckItemPoint = ZJlimitFourthPoint;
                }
                String s = df.format(ZJcheckItemPoint);

                point1+=ZJcalculatePoint6 + ZJnoProblemPoint;
                point2+=ZJcalculateTruePoint + ZJnoProblemPoint;
                //ZJpoint += ZJcheckItemPoint * pointsCalculate.getPercentInstance(ZJpart2InnerObject.getString("weight3")) / ZJfourthPointsCalculateArray.size();
            }
            ZJthirdPoint =(point1/point2)*100;
            ZJMap.put("type", ZJtype);
            String ZJthird = df.format(ZJthirdPoint);
            ZJMap.put("thirdPoint", ZJthird);
            //综合评分
            if (scAllPoint == 0) {
                ZJallOverPoint = allsecondPoint * 0.6 + ZJthirdPoint * 0.4;
            } else {
                ZJallOverPoint = scAllPoint * 0.3 + allsecondPoint * 0.4 + ZJthirdPoint * 0.3;
            }
            String ZJallOver = df.format(ZJallOverPoint);
            ZJMap.put("allOverPoint", ZJallOver);

            ZJList.add(ZJMap);
        }
        dataMap.put("ZJList", ZJList);

        //实测实量没有？？？
        //以下部分没有权重？

        //第一部分 --------- 二、评估结果 -------（二）分项评估结果 ------- 2.质量隐患
        //problemNum呢？
        List<Object> zlProblemList = new ArrayList<Object>();
        List<ProblemCollectDetail> ZJZLList = problemCollectDetailMapper.getAllInfoByFirstId(checkId, 628);
        for (int i = 0; i < ZJZLList.size(); i++) {
            Map<String, Object> zjZLMap = new HashMap<String, Object>();
            ProblemCollectDetail problemCollectDetail = ZJZLList.get(i);
            //报告的序号没改动
            zjZLMap.put("no", i + 1);
            zjZLMap.put("pName3", problemCollectDetail.getpName3());
            zjZLMap.put("pName4", problemCollectDetail.getpName4());
            if(problemCollectDetail.getIsRemark().equals("N"))
            {
                zjZLMap.put("problemDescription", problemCollectDetail.getProblemDescription());
            }else if(problemCollectDetail.getIsRemark().equals("Y"))
            {
                zjZLMap.put("problemDescription", problemCollectDetail.getRemark());
            }
            zjZLMap.put("riskPoint", problemCollectDetail.getRiskPoint());
            zlProblemList.add(zjZLMap);
        }
        dataMap.put("zlProblemList", zlProblemList);
        //第一部分 --------- 二、评估结果 -------（二）分项评估结果 ------- 3.管理行为
        //主题怎么实现的？
        StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
        //设置标题字体
        standardChartTheme.setExtraLargeFont(new Font("隶书", Font.BOLD, 20));
        //设置图例的字体
        standardChartTheme.setRegularFont(new Font("宋书", Font.PLAIN, 15));
        //设置轴向的字体
        standardChartTheme.setLargeFont(new Font("宋书", Font.PLAIN, 15));
        //应用主题样式
        int width = 718;
        int height = 468;
        ChartFactory.setChartTheme(standardChartTheme);

        List<Object> zjglList = new ArrayList<Object>();
        //736管理行为
        List<Integer> ZJGLList = problemCollectDetailMapper.getAllThirdIdByFirstId(checkId, 736);
        //List<ProblemCollectDetail> ZJGLList=problemCollectDetailMapper.getAllInfoByFirstId(checkId,736);
        for (int i = 0; i < ZJGLList.size(); i++) {
            //JFreeChart，画图的
            DefaultPieDataset datasetPie = new DefaultPieDataset();

            //zjglInnerList里装zjGLInnerMap
            List<Object> zjglInnerList = new ArrayList<Object>();
            Map<String, Object> zjGLMap = new HashMap<String, Object>();
            zjGLMap.put("pName3", prefixsystemMapper.getName4ByName4Id(ZJGLList.get(i)));
            List<ProblemCollectDetail> ZJGL3List = problemCollectDetailMapper.getZJSixthPoint(checkId, ZJGLList.get(i));
            int zjglProblem3AllNum = problemCollectDetailMapper.getZJGLProblemNumByThirdId(checkId, ZJGLList.get(i));
            for (int j = 0; j < ZJGL3List.size(); j++) {
                Map<String, Object> zjGLInnerMap = new HashMap<String, Object>();
                ProblemCollectDetail problemCollectDetail3 = ZJGL3List.get(j);
                zjGLInnerMap.put("num", j + 1);
                zjGLInnerMap.put("pName4", problemCollectDetail3.getpName6());
                int zjglProblem3Num = problemCollectDetailMapper.getZJGLProblemNumBySixthId(checkId, problemCollectDetail3.getSixthId());
                zjGLInnerMap.put("problemNum", zjglProblem3Num);
                //一个根据第六级算的，一个根据第三级算的
                zjGLInnerMap.put("percent", pointsCalculate.caculateToPercent(zjglProblem3Num, zjglProblem3AllNum));
                zjglInnerList.add(zjGLInnerMap);
                datasetPie.setValue(problemCollectDetail3.getpName4() + ":" + pointsCalculate.caculateToPercent(zjglProblem3Num, zjglProblem3AllNum), new Double(zjglProblem3Num));
            }

            try {
                //画图
                JFreeChart chart = ChartFactory.createPieChart("管理行为问题分布饼图", datasetPie, true, true, false);
                final PiePlot plot = (PiePlot) chart.getPlot();
                plot.setStartAngle(270);
                plot.setForegroundAlpha(0.90f);
                plot.setInteriorGap(0.02);
                chart.getLegend().setVisible(false);
                //File pieChart = new File("C:\\Users\\96500\\Desktop\\test\\" + fileName + "pieChart.png");
                File pieChart = new File(IMG_PATH + fileName + i + "pieChart.png");
                ChartUtils.saveChartAsPNG(pieChart, chart, width, height);
            } catch (Exception e) {
                e.printStackTrace();
            }

            zjGLMap.put("pic", MDoc.getImageStr(IMG_PATH + fileName + i + "pieChart.png"));
            zjGLMap.put("zjglInnerList", zjglInnerList);
            zjglList.add(zjGLMap);
        }
        dataMap.put("zjglList", zjglList);

        //第二部分 ------- 质量隐患具体检查情况
        String section2pName3 = "";
        List<Integer> name3List = problemCollectDetailMapper.getAllThirdIdByFirstId(checkId, 628);
        List<Object> section2List = new ArrayList<Object>();
        for (int b = 0; b < name3List.size(); b++) {
            Map<String, Object> section2Name3Map = new HashMap<String, Object>();
            List<Object> section2name3List = new ArrayList<Object>();
            section2pName3 = prefixsystemMapper.getName4ByName4Id(name3List.get(b));
            section2Name3Map.put("section2pName3", section2pName3);

            List<Object> section2Name4Info = problemCollectDetailMapper.getAllName4ByThirdId(checkId, name3List.get(b));
            String section2Name44 = JSON.toJSONString(section2Name4Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray section2Name4Array = JSONArray.parseArray(section2Name44);
            for (int w = 0; w < section2Name4Array.size(); w++) {
                Map<String, Object> section2Name4Map = new HashMap<String, Object>();
                List<Object> section2Name4List = new ArrayList<Object>();
                int section2Name4Id = section2Name4Array.getIntValue(w);

                String section2Name4 = prefixsystemMapper.getName4ByName4Id(section2Name4Id);
                //为社么叫name6
                List<ProblemCollectDetail> section2Name6Info = problemCollectDetailMapper.getAllName6InfoByName4(checkId, section2Name4Id, "质量检查");
                String section2Name66 = JSON.toJSONString(section2Name6Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray section2Name6Array = JSONArray.parseArray(section2Name66);
                for (int c = 0; c < section2Name6Array.size(); c++) {
                    Map<String, Object> section2Name6Map = new HashMap<String, Object>();
                    List<Object> picList = new ArrayList<Object>();
                    JSONObject section2Name6Object = section2Name6Array.getJSONObject(c);
                    section2Name6Map.put("section2pName6No", c + 1);
                    section2Name6Map.put("section2pName6", section2Name6Object.getString("pName6"));
                    section2Name6Map.put("section2pName5", section2Name6Object.getString("pName5"));
                    section2Name6Map.put("section2RiskLevel", section2Name6Object.getString("riskPoint"));
                    section2Name6Map.put("section2CheckPart", section2Name6Object.getString("checkPart"));
                    section2Name6Map.put("section2ProblemNum", section2Name6Object.getString("problemQua"));
                    if (section2Name6Object.getString("isRemark").equals("N")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("problemDescription"));
                    } else if (section2Name6Object.getString("isRemark").equals("Y")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("remark"));
                    }
                    section2Name6Map.put("section2normsProvison", section2Name6Object.getString("normsProvison"));
                    section2Name6Map.put("section2suggestion", section2Name6Object.getString("suggestion"));
                    String section2picPath = section2Name6Object.getString("picPath");
                    String picName = section2Name6Object.getString("picName");
                    JSONArray ja = JSONArray.parseArray(picName);
                    if (ja.size() == 0) {
                        //String s = MDoc.getImageStr("C:\\Users\\96500\\Desktop\\20190329183836002.png");
                        String s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                        picList.add(s);
                    } else {
                        for (int o = 0; o < ja.size(); o++) {
                            String s="";
                            if("prod".equals(profiles.getActives())){
                                s = MDoc.getImageStr(section2picPath + ja.getString(o));
                            }
                            //String s = MDoc.getImageStr("C:\\Users\\96500\\Desktop\\20190329183836002.png");
                            picList.add(s);
                        }
                    }
                    section2Name6Map.put("picList", picList);
                    section2Name4List.add(section2Name6Map);

                }
                section2Name4Map.put("section2pName4", section2Name4);
                section2Name4Map.put("section2Name4List", section2Name4List);
                section2name3List.add(section2Name4Map);
            }
            section2Name3Map.put("section2Name3List", section2name3List);
            section2List.add(section2Name3Map);
        }
        dataMap.put("section2List", section2List);

        //第三部分 ------- 管理行为具体检查情况
        //同上
        String section3pName3 = "";
        List<Integer> glName3List = problemCollectDetailMapper.getAllThirdIdByFirstId(checkId, 736);
        List<Object> section3List = new ArrayList<Object>();
        for (int b = 0; b < glName3List.size(); b++) {
            Map<String, Object> section3Name3Map = new HashMap<String, Object>();
            List<Object> section3name3List = new ArrayList<Object>();
            section3pName3 = prefixsystemMapper.getName4ByName4Id(glName3List.get(b));
            section3Name3Map.put("section3pName3", section3pName3);
            List<Object> section3Name4Info = problemCollectDetailMapper.getAllName4ByThirdId(checkId, glName3List.get(b));
            String section3Name44 = JSON.toJSONString(section3Name4Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray section3Name4Array = JSONArray.parseArray(section3Name44);
            for (int w = 0; w < section3Name4Array.size(); w++) {
                Map<String, Object> section3Name4Map = new HashMap<String, Object>();
                List<Object> section3Name4List = new ArrayList<Object>();
                int section3Name4Id = section3Name4Array.getIntValue(w);
                String section3Name4 = prefixsystemMapper.getName4ByName4Id(section3Name4Id);
                List<ProblemCollectDetail> section3Name6Info = problemCollectDetailMapper.getAllName6InfoByName4(checkId, section3Name4Id, "管理行为");
                String section3Name66 = JSON.toJSONString(section3Name6Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray section3Name6Array = JSONArray.parseArray(section3Name66);
                for (int c = 0; c < section3Name6Array.size(); c++) {
                    Map<String, Object> section3Name6Map = new HashMap<String, Object>();
                    List<Object> picList = new ArrayList<Object>();
                    JSONObject section3Name6Object = section3Name6Array.getJSONObject(c);
                    section3Name6Map.put("section3pName6No", c + 1);
                    section3Name6Map.put("section3pName6", section3Name6Object.getString("pName6"));
                    section3Name6Map.put("section3pName5", section3Name6Object.getString("pName5"));
                    section3Name6Map.put("section3RiskLevel", section3Name6Object.getString("riskPoint"));
                    section3Name6Map.put("section3CheckPart", section3Name6Object.getString("checkPart"));
                    section3Name6Map.put("section3ProblemNum", section3Name6Object.getString("problemQua"));
                    if (section3Name6Object.getString("isRemark").equals("N")) {
                        section3Name6Map.put("section3problemDescription", section3Name6Object.getString("problemDescription"));
                    } else if (section3Name6Object.getString("isRemark").equals("Y")) {
                        section3Name6Map.put("section3problemDescription", section3Name6Object.getString("remark"));
                    }
                    section3Name6Map.put("section3normsProvison", section3Name6Object.getString("normsProvison"));
                    section3Name6Map.put("section3suggestion", section3Name6Object.getString("suggestion"));
                    String section3picPath = section3Name6Object.getString("picPath");
                    String picName = section3Name6Object.getString("picName");
                    JSONArray ja = JSONArray.parseArray(picName);
                    if (ja.size() == 0) {
                        //String s = MDoc.getImageStr("C:\\Users\\96500\\Desktop\\20190329183836002.png");
                        String s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                        picList.add(s);
                    } else {
                        for (int o = 0; o < ja.size(); o++) {
                            String s="";
                            if("prod".equals(profiles.getActives())){
                                s = MDoc.getImageStr(section3picPath + ja.getString(o));
                            }
                            //String s = MDoc.getImageStr("C:\\Users\\96500\\Desktop\\20190329183836002.png");
                            picList.add(s);
                        }
                    }
                    section3Name6Map.put("picList", picList);
                    section3Name4List.add(section3Name6Map);

                }
                section3Name4Map.put("section3pName4", section3Name4);
                section3Name4Map.put("section3Name4List", section3Name4List);
                section3name3List.add(section3Name4Map);
            }
            section3Name3Map.put("section3Name3List", section3name3List);
            section3List.add(section3Name3Map);
        }
        dataMap.put("section3List", section3List);

        //第四部分 ------- 改进建议
        List<Object> pName1Info = problemCollectDetailMapper.getAllName1Id(checkId);
        String name1 = JSON.toJSONString(pName1Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray name1Array = JSONArray.parseArray(name1);
        List<Object> part4List = new ArrayList<Object>();
        for (int i = 0; i < name1Array.size(); i++) {
            List<Object> part4InnerList = new ArrayList<Object>();
            Map<String, Object> part4Map = new HashMap<String, Object>();
            String pName1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(i));
            //改进建议
            List<Summary> summaryList = summaryMapper.getSummaryInfo(checkId, name1Array.getIntValue(i));
            String summaryInfo = JSON.toJSONString(summaryList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray summaryInfoArray = JSONArray.parseArray(summaryInfo);
            for (int j = 0; j < summaryInfoArray.size(); j++) {
                Map<String, Object> part4InnerMap = new HashMap<String, Object>();
                JSONObject part4InnerObject = summaryInfoArray.getJSONObject(j);
                String part4pNname4 = prefixsystemMapper.getName4ByName4Id(part4InnerObject.getIntValue("fourthId"));

                //拿到上一级的名字，即name3
                Prefixsystem prefixsystem = prefixsystemMapper.getFather(part4InnerObject.getIntValue("fourthId"));
                String part4pName3 = prefixsystemMapper.getName4ByName4Id(prefixsystem.getPreNum());

                part4InnerMap.put("pName3", part4pName3);
                part4InnerMap.put("no", j + 1);
                part4InnerMap.put("pName4", part4pNname4);
                part4InnerMap.put("summary", part4InnerObject.getString("summary"));
                part4InnerList.add(part4InnerMap);
            }
            part4Map.put("name1", pName1);
            part4Map.put("part4InnerList", part4InnerList);
            part4List.add(part4Map);
        }
        dataMap.put("part4List", part4List);

        MDoc mdoc = new MDoc();
        String path = FileUtil.getServerFolderPath();
        File f1 = new File(path, "doc");
        if (!f1.exists()) {
            f1.mkdirs();
        }
        mdoc.createDoc(dataMap, path + "\\doc\\" + projectObject.getString("projectName").replace('#','号')+"质量专项报告"+fileName + ".doc", "ftl\\ZJ2.0.ftl");
        //MDoc.docToDocx("D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\"+ projectObject.getString("projectName").replace('#','号')+"质量专项报告"+fileName + ".doc", "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + projectObject.getString("projectName").replace('#','号')+"质量专项报告"+fileName +".doc");
        String result = urlProperties.getAddress()+"/doc/"  + projectObject.getString("projectName").replace('#','号')+"质量专项报告"+fileName +".doc";
        return result;
    }

    @Override
    public String generateReportType3(int projectId, int checkId) throws UnsupportedEncodingException {
        Integer taskId = contractchecktaskMapper.getTaskIdByCheckId(checkId);
        DecimalFormat df = new DecimalFormat("0.00");
        Map<String, Object> dataMap = new HashMap<String, Object>();
        Date date = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        DateFormat d2 = new SimpleDateFormat("yyyy");
        DateFormat d3 = new SimpleDateFormat("MM");
        DateFormat d4 = new SimpleDateFormat("dd");
        String day = d4.format(date);
        String month = d3.format(date);
        String year = d2.format(date);
        String fileName = d1.format(date);
        dataMap.put("day", day);
        dataMap.put("month", month);
        dataMap.put("year", year);
        List<String> type3List = new ArrayList<String>();
        type3List.add("2");
        type3List.add("3");
        type3List.add("4");
        //工程概况部分，来自ctp的工程信息
        List<ContractTaskProject> projectList = contracttaskprojectMapper.selectAllByCheckId(projectId);
        String project = JSON.toJSONString(projectList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray projectArray = JSONArray.parseArray(project);
        JSONObject projectObject = projectArray.getJSONObject(0);
        dataMap.put("projectName", projectObject.getString("projectName"));
        dataMap.put("projectAddress", projectObject.getString("area"));
        dataMap.put("jsUnit", projectObject.getString("jsUnit"));
        dataMap.put("jlUnit", projectObject.getString("jlUnit"));
        dataMap.put("sgUnit", projectObject.getString("sgUnit"));
        dataMap.put("projectType", projectObject.getString("projectType"));
        dataMap.put("projectPrice", projectObject.getString("projectPrice"));
        dataMap.put("dangerItem", projectObject.getString("dangerItem"));
        dataMap.put("remark", projectObject.getString("remark"));
        dataMap.put("projectDescription", projectObject.getString("projectDescription"));
        String js = projectObject.getString("jsUniter");
        String jl = projectObject.getString("jlUniter");
        String sg = projectObject.getString("manager");
        dataMap.put("jsUniter", js);
        dataMap.put("jlUniter", jl);
        dataMap.put("sgUniter", sg);
        //工程概况部分，来自设备信息表的设备信息部分
        List<Equipinfo> equipinfoList = equipinfoMapper.getAllByProjectId(projectId);
        String equip = JSON.toJSONString(equipinfoList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray equipArray = JSONArray.parseArray(equip);
        List<Object> equipList = new ArrayList<Object>();
        if (equipArray.size() == 0) {
            Map<String, Object> eqMap = new HashMap<String, Object>();
            eqMap.put("equipType", "\\");
            eqMap.put("equipQua", "\\");
            eqMap.put("equipNum", "\\");
            eqMap.put("equipLeaseUnit", "\\");
            eqMap.put("equipUseUnit", "\\");
            eqMap.put("demolitionUnit", "\\");
            eqMap.put("testUnit", "\\");
            equipList.add(eqMap);
        } else {
            for (int i = 0; i < equipArray.size(); i++) {
                Map<String, Object> eqMap = new HashMap<String, Object>();
                JSONObject equipObject = equipArray.getJSONObject(i);
                eqMap.put("equipType", equipObject.getString("equipType"));
                eqMap.put("equipQua", equipObject.getString("equipQua"));
                eqMap.put("equipNum", equipObject.getString("equipNum"));
                eqMap.put("equipLeaseUnit", equipObject.getString("equipLeaseUnit"));
                eqMap.put("equipUseUnit", equipObject.getString("equipUseUnit"));
                eqMap.put("demolitionUnit", equipObject.getString("demolitionUnit"));
                eqMap.put("testUnit", equipObject.getString("testUnit"));
                equipList.add(eqMap);
            }
        }
        dataMap.put("equipList", equipList);

        //第一部分，（二）分项评估结果
        String ZJname1 = "[1]";
        double allsecondPoint = 0;
        JSONArray ZJname1Array = JSONArray.parseArray(ZJname1);
        float allExtraPointFloat = problemCollectDetailMapper.getAllExtraPoint(checkId);
        double allExtraPoint = Double.valueOf(String.valueOf(allExtraPointFloat));
        double overAllPoint = 0;
        List<Object> part2List = new ArrayList<Object>();
        String Name1 = "";
        double allweight1 = 0;
        for (int i = 0; i < ZJname1Array.size(); i++) {
            double Tweight1 = 0;
            String weight1 = prefixsystemMapper.getWeight1ByName1(prefixsystemMapper.getName4ByName4Id(ZJname1Array.getIntValue(i)));
            Tweight1 = pointsCalculate.getPercentInstance(weight1);
            allweight1 += Tweight1;
        }
        for (int k = 0; k < ZJname1Array.size(); k++) {
            Map<String, Object> part2Map = new HashMap<String, Object>();
            List<Object> part2InnerList = new ArrayList<Object>();
            String pName1 = prefixsystemMapper.getName4ByName4Id(ZJname1Array.getIntValue(k));
            double Tweight1 = 0;
            String weight1 = prefixsystemMapper.getWeight1ByName1(pName1);
            Tweight1 = pointsCalculate.getPercentInstance(weight1);
            if (pName1.equals("安全检查")) {
                List<ProblemCollectDetail> list = problemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("aqLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "安全文明";
            } else if (pName1.equals("质量检查")) {
                List<ProblemCollectDetail> list = problemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("zlLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "质量隐患";
            } else if (pName1.equals("管理行为")) {
                List<ProblemCollectDetail> list = problemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("glLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "管理行为";
            }
            part2Map.put("name1No", k + 1);
            part2Map.put("name1", Name1);
            List<Object> secondIdList = problemCollectDetailMapper.getSecondId(checkId, pName1);
            String secondIdInfo = JSON.toJSONString(secondIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray secondIdInfoArray = JSONArray.parseArray(secondIdInfo);
            double allweight2 = 0;
            for (int p = 0; p < secondIdInfoArray.size(); p++) {
                int allsecondId = secondIdInfoArray.getIntValue(p);
                String weight2 = prefixsystemMapper.getWeight3ByThirdId(allsecondId);
                double weight22 = pointsCalculate.getPercentInstance(weight2);
                allweight2 += weight22;
            }
            for (int u = 0; u < secondIdInfoArray.size(); u++) {
                int secondId = secondIdInfoArray.getIntValue(u);
                double weight222 = 0;
                String weight2 = prefixsystemMapper.getWeight3ByThirdId(secondId);
                weight222 = pointsCalculate.getPercentInstance(weight2);
                List<ProblemCollectDetail> fourthPoints = problemCollectDetailMapper.getFourthPoint(checkId, pName1, secondId);
                String fourthCalculateInfo = JSON.toJSONString(fourthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray fourthPointsCalculateArray = JSONArray.parseArray(fourthCalculateInfo);
                double point = 0;
                for (int j = 0; j < fourthPointsCalculateArray.size(); j++) {
                    Map<String, Object> part2InnerMap = new HashMap<String, Object>();
                    JSONObject part2InnerObject = fourthPointsCalculateArray.getJSONObject(j);
                    part2InnerMap.put("pName4", part2InnerObject.getString("pName4"));
                    double weight3 = 0;
                    int part2FourthId = part2InnerObject.getIntValue("fourthId");
                    int part2InnerProblemNum = problemCollectDetailMapper.getProblemNumByFourthId(checkId, part2FourthId);
                    int riskPointOver3Num = problemCollectDetailMapper.getProblemNumOver3(checkId, part2FourthId, type3List);
                    part2InnerMap.put("problemNum", part2InnerProblemNum);
                    part2InnerMap.put("riskPointNum", riskPointOver3Num);
                    int part2ThirdId = part2InnerObject.getIntValue("thirdId");
//                    weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));

                    String newWeight3 = editableweightpsMapper.getWeightByNumber(part2ThirdId,taskId);
                    if(StringUtils.isNotBlank(newWeight3)){
                        weight3 = pointsCalculate.getPercentInstance(newWeight3);
                    }else {
                        weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
                    }

                    List<Object> fourthCountList = problemCollectDetailMapper.getFourthCountList(checkId, part2ThirdId);
                    String fourthCountInfo = JSON.toJSONString(fourthCountList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray fourthCountInfoArray = JSONArray.parseArray(fourthCountInfo);
                    int countFourthId = fourthCountInfoArray.size();
                    part2InnerMap.put("weight4", pointsCalculate.doubleToPercent(weight3, countFourthId));
                    List<ProblemCollectDetail> sixthPoints = problemCollectDetailMapper.getsixthPoints(checkId, part2FourthId);
                    String pointName6Info = JSON.toJSONString(sixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray sixthPointsArray = JSONArray.parseArray(pointName6Info);
                    double calculatePoint6 = 0;
                    double calculatePoint66 = 0;
                    double calculateTruePoint = 0;
                    for (int y = 0; y < sixthPointsArray.size(); y++) {
                        JSONObject sixPointObject = sixthPointsArray.getJSONObject(y);
                        int deductSixthId = sixPointObject.getIntValue("sixthId");
                        float deductPointsSumFloat = problemCollectDetailMapper.getdeductSum(checkId, deductSixthId);
                        double deductPointsSum = Double.valueOf(String.valueOf(deductPointsSumFloat));
                        double truePoint = Double.parseDouble(sixPointObject.getString("point6"));
                        if (truePoint <= deductPointsSum) {
                            calculatePoint66 = 0;
                        } else {
                            calculatePoint66 = truePoint - deductPointsSum;
                        }
                        calculateTruePoint += truePoint;
                        calculatePoint6 += calculatePoint66;
                    }
                    double noProblemPoint = 0;
                    List<Object> noProblemSixthIdList = uncheckeditemsMapper.getNoProblemSixthId(checkId, part2InnerObject.getIntValue("fourthId"));
                    String noProblemSixthIdInfo = JSON.toJSONString(noProblemSixthIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray noProblemSixthArray = JSONArray.parseArray(noProblemSixthIdInfo);
                    for (int m = 0; m < noProblemSixthArray.size(); m++) {
                        int noProblemSixthId = noProblemSixthArray.getIntValue(m);
                        double noProblem = Double.parseDouble(prefixsystemMapper.getPoint4ByPoint4Id(noProblemSixthId));
                        noProblemPoint += noProblem;
                    }
                    double checkItemPoint = (calculatePoint6 + noProblemPoint) / (calculateTruePoint + noProblemPoint) * 100;
                    List<ProblemCollectDetail> checkItemCalcuList = problemCollectDetailMapper.getAllFourthInfo(checkId, part2FourthId);
                    String maxFourthRiskPoint = pointsCalculate.getMaxRiskPoint(checkItemCalcuList);
                    int maxFourthRiskPointNum = problemCollectDetailMapper.getRiskPointCount(checkId, part2FourthId, maxFourthRiskPoint);
                    double limitFourhPoint = Double.parseDouble((pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint)) == null ? "100" : pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint));
                    if (checkItemPoint > limitFourhPoint) {
                        checkItemPoint = limitFourhPoint;
                    }
                    String s = df.format(checkItemPoint);
                    part2InnerMap.put("checkItemPoint", s);
                    int allPointSaveFourthPointCount = allpointsaveMapper.getAllPointCountByCheckId(checkId, part2FourthId);
                    if (allPointSaveFourthPointCount != 0) {
                        SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                        Date date1 = new Date(System.currentTimeMillis());
                        String lastEditTime=formatter.format(date1);
                        allpointsaveMapper.updateAllPoint(checkId, s, part2FourthId,lastEditTime);
                    } else {
                        Allpointsave allpointsave = new Allpointsave();
                        SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                        Date date1 = new Date(System.currentTimeMillis());
                        allpointsave.setNewCreateTime(formatter.format(date1));
                        allpointsave.setLastEditTime(formatter.format(date1));
                        allpointsave.setProjectId(projectId);
                        allpointsave.setCheckId(checkId);
                        allpointsave.setNumber(part2FourthId);
                        allpointsave.setPoint(s);
                        allpointsaveMapper.insert(allpointsave);
                    }
                    point += checkItemPoint * weight3 / countFourthId;
                    part2InnerList.add(part2InnerMap);
                }

                List<ProblemCollectDetail> noProblemItemList = problemCollectDetailMapper.getNoProblemItem(checkId, secondId);
                String noProblemCalculateInfo = JSON.toJSONString(noProblemItemList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray noProblemCalculateArray = JSONArray.parseArray(noProblemCalculateInfo);
                for (int j = 0; j < noProblemCalculateArray.size(); j++) {
                    Map<String, Object> part2InnerMap = new HashMap<String, Object>();
                    JSONObject part2InnerObject = noProblemCalculateArray.getJSONObject(j);
                    part2InnerMap.put("pName4", "无问题项");
                    double weight3 = 0;
                    int part2FourthId = part2InnerObject.getIntValue("fourthId");
                    int part2InnerProblemNum = problemCollectDetailMapper.getProblemNumByFourthId(checkId, part2FourthId);
                    int riskPointOver3Num = problemCollectDetailMapper.getProblemNumOver3(checkId, part2FourthId, type3List);
                    part2InnerMap.put("problemNum", part2InnerProblemNum);
                    part2InnerMap.put("riskPointNum", riskPointOver3Num);
                    int part2ThirdId = part2InnerObject.getIntValue("thirdId");
 //                   weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
                    String newWeight3 = editableweightpsMapper.getWeightByNumber(part2ThirdId,taskId);
                    if(StringUtils.isNotBlank(newWeight3)){
                        weight3 = pointsCalculate.getPercentInstance(newWeight3);
                    }else {
                        weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
                    }

                    List<Object> fourthCountList = problemCollectDetailMapper.getFourthCountList(checkId, part2ThirdId);
                    String fourthCountInfo = JSON.toJSONString(fourthCountList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray fourthCountInfoArray = JSONArray.parseArray(fourthCountInfo);
                    int countFourthId = fourthCountInfoArray.size();
                    part2InnerMap.put("weight4", pointsCalculate.doubleToPercent(weight3, countFourthId));
                    List<ProblemCollectDetail> sixthPoints = problemCollectDetailMapper.getsixthPoints(checkId, part2FourthId);
                    String pointName6Info = JSON.toJSONString(sixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray sixthPointsArray = JSONArray.parseArray(pointName6Info);
                    double calculatePoint6 = 0;
                    double calculatePoint66 = 0;
                    double calculateTruePoint = 0;
                    for (int y = 0; y < sixthPointsArray.size(); y++) {
                        JSONObject sixPointObject = sixthPointsArray.getJSONObject(y);
                        int deductSixthId = sixPointObject.getIntValue("sixthId");
                        float deductPointsSumFloat = problemCollectDetailMapper.getdeductSum(checkId, deductSixthId);
                        double deductPointsSum = Double.valueOf(String.valueOf(deductPointsSumFloat));
                        double truePoint = Double.parseDouble(sixPointObject.getString("point6"));
                        if (truePoint <= deductPointsSum) {
                            calculatePoint66 = 0;
                        } else {
                            calculatePoint66 = truePoint - deductPointsSum;
                        }
                        calculateTruePoint += truePoint;
                        calculatePoint6 += calculatePoint66;
                    }
                    double noProblemPoint = 0;
                    List<Object> noProblemSixthIdList = uncheckeditemsMapper.getNoProblemSixthId(checkId, part2InnerObject.getIntValue("fourthId"));
                    String noProblemSixthIdInfo = JSON.toJSONString(noProblemSixthIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray noProblemSixthArray = JSONArray.parseArray(noProblemSixthIdInfo);
                    for (int m = 0; m < noProblemSixthArray.size(); m++) {
                        int noProblemSixthId = noProblemSixthArray.getIntValue(m);
                        double noProblem = Double.parseDouble(prefixsystemMapper.getPoint4ByPoint4Id(noProblemSixthId));
                        noProblemPoint += noProblem;
                    }
                    double checkItemPoint = (calculatePoint6 + noProblemPoint) / (calculateTruePoint + noProblemPoint) * 100;
                    List<ProblemCollectDetail> checkItemCalcuList = problemCollectDetailMapper.getAllFourthInfo(checkId, part2FourthId);
                    String maxFourthRiskPoint = pointsCalculate.getMaxRiskPoint(checkItemCalcuList);
                    int maxFourthRiskPointNum = problemCollectDetailMapper.getRiskPointCount(checkId, part2FourthId, maxFourthRiskPoint);
                    double limitFourhPoint = Double.parseDouble((pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint)) == null ? "100" : pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint));
                    if (checkItemPoint > limitFourhPoint) {
                        checkItemPoint = limitFourhPoint;
                    }
                    String s = df.format(checkItemPoint);
                    part2InnerMap.put("checkItemPoint", s);
                    int allPointSaveFourthPointCount = allpointsaveMapper.getAllPointCountByCheckId(checkId, part2FourthId);
                    if (allPointSaveFourthPointCount != 0) {
                        SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                        Date date1 = new Date(System.currentTimeMillis());
                        String lastEditTime=formatter.format(date1);
                        allpointsaveMapper.updateAllPoint(checkId, s, part2FourthId,lastEditTime);
                    } else {
                        Allpointsave allpointsave = new Allpointsave();
                        SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                        Date date1 = new Date(System.currentTimeMillis());
                        allpointsave.setNewCreateTime(formatter.format(date1));
                        allpointsave.setLastEditTime(formatter.format(date1));
                        allpointsave.setProjectId(projectId);
                        allpointsave.setCheckId(checkId);
                        allpointsave.setNumber(part2FourthId);
                        allpointsave.setPoint(s);
                        allpointsaveMapper.insert(allpointsave);
                    }
                    //point += checkItemPoint * weight3 / countFourthId;
                    part2InnerList.add(part2InnerMap);
                }

                List<Object> getThirdId = problemCollectDetailMapper.getThirdId(checkId, pName1, secondId);
                String thirdIdInfo = JSON.toJSONString(getThirdId, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray thirdArray = JSONArray.parseArray(thirdIdInfo);

                double allweight3 = 0;
                for (int v = 0; v < thirdArray.size(); v++) {
                    double Tweight3 = 0;
                    int thirdId = thirdArray.getIntValue(v);
//                    String trueweight3 = prefixsystemMapper.getWeight3ByThirdId(thirdId);
//                    Tweight3 = pointsCalculate.getPercentInstance(trueweight3);
                    String newWeight3 = editableweightpsMapper.getWeightByNumber(thirdId, taskId);
                    if(StringUtils.isNotBlank(newWeight3)){
                        Tweight3 = pointsCalculate.getPercentInstance(newWeight3);
                    }else{
                        String trueweight3 = prefixsystemMapper.getWeight3ByThirdId(thirdId);
                        Tweight3 = pointsCalculate.getPercentInstance(trueweight3);
                    }
                    allweight3 += Tweight3;
                }
                double thirdPoint = Double.parseDouble(df.format(point / allweight3));
                double percent2 = Double.parseDouble(df.format(weight222 / allweight2));
                double secondPoint = Double.parseDouble(df.format(thirdPoint * percent2));
                allsecondPoint += secondPoint;
            }
            if (pName1.equals("安全检查")) {
                dataMap.put("aqPoint", allsecondPoint);
            } else if (pName1.equals("质量检查")) {
                dataMap.put("zlPoint", allsecondPoint);
            } else if (pName1.equals("管理行为")) {
                dataMap.put("glPoint", allsecondPoint);
            }
            int firstPointCount = allpointsaveMapper.getAllPointCountByCheckId(checkId, 1);
            if (firstPointCount != 0) {
                SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                Date date1 = new Date(System.currentTimeMillis());
                String lastEditTime=formatter.format(date1);
                allpointsaveMapper.updateAllPoint(checkId, df.format(allsecondPoint), 1,lastEditTime);
            } else {
                Allpointsave allpointsave = new Allpointsave();
                SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                Date date1 = new Date(System.currentTimeMillis());
                allpointsave.setNewCreateTime(formatter.format(date1));
                allpointsave.setLastEditTime(formatter.format(date1));
                allpointsave.setCheckId(checkId);
                allpointsave.setNumber(1);
                allpointsave.setPoint(df.format(allsecondPoint));
                allpointsave.setProjectId(projectId);
                allpointsaveMapper.insert(allpointsave);
            }
            double trueWeight1 = Double.parseDouble(df.format(Tweight1 / allweight1));
            overAllPoint += Double.parseDouble(df.format(trueWeight1 * allsecondPoint));
            part2Map.put("point", allsecondPoint);
            part2Map.put("part2InnerList", part2InnerList);
            part2List.add(part2Map);
        }
        List<ProblemCollectDetail> overallList = problemCollectDetailMapper.getAllProblemCollectInfoByCheckId(checkId);
        ContractTaskProject contractTaskProjectRiskPoint = new ContractTaskProject();
        SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
        Date date1 = new Date(System.currentTimeMillis());
        contractTaskProjectRiskPoint.setLastEditTime(formatter.format(date1));
        contractTaskProjectRiskPoint.setProjectId(projectId);
        contractTaskProjectRiskPoint.setLatestRiskLevel(pointsCalculate.getMaxRiskPoint(overallList));
        contracttaskprojectMapper.updateByPrimaryKeySelective(contractTaskProjectRiskPoint);
        ContractTaskProject newRiskList = contracttaskprojectMapper.selectByPrimaryKey(projectId);
        String finishTime = contractchecktaskMapper.getFinishTimeByCheckId(checkId);
        if (newRiskList.getCheckTime().equals("") || newRiskList.getCheckTime().compareTo(finishTime) <= 0) {
            try {
                ContractTaskProject contracttaskproject = new ContractTaskProject();
                contracttaskproject.setLastEditTime(formatter.format(date1));
                contracttaskproject.setProjectId(projectId);
                contracttaskproject.setLatestCheckTime(finishTime);
                contracttaskprojectMapper.updateByPrimaryKeySelective(contracttaskproject);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        dataMap.put("part2List", part2List);


        //分项评估结果与综合评估结果
        List<Integer> ZJThirdIdList = problemCollectDetailMapper.getAllZJthirdId(checkId, 1385);
        List<Object> ZJList = new ArrayList<Object>();
        for (int t = 0; t < ZJThirdIdList.size(); t++) {
            Map<String, Object> ZJMap = new HashMap<String, Object>();
            ZJMap.put("aqPoint", "\\");
            ZJMap.put("hjPoint", "\\");
            String ZJtype = "";
            double ZJallOverPoint = 0;
            double ZJthirdPoint = 0;
            double ZJaqPoint = 0;
            double ZJhjPoint = 0;
            ZJMap.put("thirdPoint", "\\");
            ZJMap.put("No", t + 1);
            ZJMap.put("aqAllPoint", allsecondPoint);
            ZJMap.put("pName3", prefixsystemMapper.getName4ByName4Id(ZJThirdIdList.get(t)));
            switch (prefixsystemMapper.getName4ByName4Id(ZJThirdIdList.get(t))) {
                case "项目公司":
                    ZJtype = "投资管理";
                    break;
                case "监理":
                    ZJtype = "投资管理";
                    break;
                case "施工总承包(投资管理)":
                    ZJtype = "投资管理";
                    break;
                case "指挥部":
                    ZJtype = "EPC咨询管理";
                    break;
                case "施工总承包":
                    ZJtype = "EPC咨询管理";
                    break;
                case "工程总承包项目部":
                    ZJtype = "EPC工程总承包管理";
                    break;
                case "PC工厂":
                    ZJtype = "PC生产管理";
                    break;
                default:
                    ZJtype = "";
                    break;
            }
            ZJMap.put("problemNum", problemCollectDetailMapper.getProblemNumByThirdId(checkId, ZJThirdIdList.get(t)));
            ZJMap.put("riskPoint", problemCollectDetailMapper.getRiskPointNumOver3ByThirdId(checkId, ZJThirdIdList.get(t), type3List));
            List<ProblemCollectDetail> ZJfourthPoints = problemCollectDetailMapper.getZJFourthPoint(checkId, ZJThirdIdList.get(t));
            String ZJfourthCalculateInfo = JSON.toJSONString(ZJfourthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray ZJfourthPointsCalculateArray = JSONArray.parseArray(ZJfourthCalculateInfo);
            for (int j = 0; j < ZJfourthPointsCalculateArray.size(); j++) {
                JSONObject ZJpart2InnerObject = ZJfourthPointsCalculateArray.getJSONObject(j);
                int ZJpart2FourthId = ZJpart2InnerObject.getIntValue("fourthId");
                List<ProblemCollectDetail> ZJsixthPoints = problemCollectDetailMapper.getZJsixthPoints(checkId, ZJpart2FourthId);
                String ZJpointName6Info = JSON.toJSONString(ZJsixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray ZJsixthPointsArray = JSONArray.parseArray(ZJpointName6Info);
                double ZJcalculatePoint6 = 0;
                double ZJcalculatePoint66 = 0;
                double ZJcalculateTruePoint = 0;
                for (int y = 0; y < ZJsixthPointsArray.size(); y++) {
                    JSONObject ZJsixPointObject = ZJsixthPointsArray.getJSONObject(y);
                    int ZJdeductSixthId = ZJsixPointObject.getIntValue("sixthId");
                    float ZJdeductPointsSumFloat = problemCollectDetailMapper.getdeductSum(checkId, ZJdeductSixthId);
                    double ZJdeductPointsSum = Double.valueOf(String.valueOf(ZJdeductPointsSumFloat));
                    double ZJtruePoint = Double.parseDouble(ZJsixPointObject.getString("point6"));
                    if (ZJtruePoint <= ZJdeductPointsSum) {
                        ZJcalculatePoint66 = 0;
                    } else {
                        ZJcalculatePoint66 = ZJtruePoint - ZJdeductPointsSum;
                    }
                    ZJcalculateTruePoint += ZJtruePoint;
                    ZJcalculatePoint6 += ZJcalculatePoint66;
                }
                double ZJnoProblemPoint = 0;
                List<Object> ZJnoProblemSixthIdList = uncheckeditemsMapper.getNoProblemSixthId(checkId, ZJpart2FourthId);
                String ZJnoProblemSixthIdInfo = JSON.toJSONString(ZJnoProblemSixthIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray ZJnoProblemSixthArray = JSONArray.parseArray(ZJnoProblemSixthIdInfo);
                for (int m = 0; m < ZJnoProblemSixthArray.size(); m++) {
                    int ZJnoProblemSixthId = ZJnoProblemSixthArray.getIntValue(m);
                    double ZJnoProblem = Double.parseDouble(prefixsystemMapper.getPoint4ByPoint4Id(ZJnoProblemSixthId));
                    ZJnoProblemPoint += ZJnoProblem;
                }
                double ZJcheckItemPoint = (ZJcalculatePoint6 + ZJnoProblemPoint) / (ZJcalculateTruePoint + ZJnoProblemPoint) * 100;
                List<ProblemCollectDetail> ZJcheckItemCalcuList = problemCollectDetailMapper.getAllFourthInfo(checkId, ZJpart2FourthId);
                String ZJmaxFourthRiskPoint = pointsCalculate.getMaxRiskPoint(ZJcheckItemCalcuList);
                int ZJmaxFourthRiskPointNum = problemCollectDetailMapper.getRiskPointCount(checkId, ZJpart2FourthId, ZJmaxFourthRiskPoint);
                double ZJlimitFourthPoint = Double.parseDouble((pointlimitMapper.getLimitPointByInfo(String.valueOf(ZJmaxFourthRiskPointNum), ZJmaxFourthRiskPoint)) == null ? "100" : pointlimitMapper.getLimitPointByInfo(String.valueOf(ZJmaxFourthRiskPointNum), ZJmaxFourthRiskPoint));
                if (ZJcheckItemPoint > ZJlimitFourthPoint) {
                    ZJcheckItemPoint = ZJlimitFourthPoint;
                }
                String s = df.format(ZJcheckItemPoint);
                if (prefixsystemMapper.getName4ByName4Id(ZJpart2FourthId).equals("安全文明")) {
                    ZJaqPoint = ZJcheckItemPoint;
                    ZJMap.put("aqPoint", s);
                } else if (prefixsystemMapper.getName4ByName4Id(ZJpart2FourthId).equals("环境管理")) {
                    ZJhjPoint = ZJcheckItemPoint;
                    ZJMap.put("hjPoint", s);
                }
            }
            if (ZJfourthPointsCalculateArray.size() == 1) {
                ZJthirdPoint = ZJaqPoint + ZJhjPoint;
            } else if (ZJfourthPointsCalculateArray.size() == 2) {
                ZJthirdPoint = ZJaqPoint * 0.7 + ZJhjPoint * 0.3;
            }
            ZJMap.put("type", ZJtype);
            String ZJthird = df.format(ZJthirdPoint);
            ZJMap.put("thirdPoint", ZJthird);
            ZJallOverPoint = allsecondPoint * 0.7 + ZJthirdPoint * 0.3;
            String ZJallOver = df.format(ZJallOverPoint);
            ZJMap.put("allOverPoint", ZJallOver);
            ZJList.add(ZJMap);
        }
        dataMap.put("ZJList", ZJList);
        //改进建议（小结）
        List<Object> pName1Info = problemCollectDetailMapper.getAllName1Id(checkId);
        String name1 = JSON.toJSONString(pName1Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray name1Array = JSONArray.parseArray(name1);
        List<Object> part4List = new ArrayList<Object>();
        for (int i = 0; i < name1Array.size(); i++) {
            List<Object> part4InnerList = new ArrayList<Object>();
            Map<String, Object> part4Map = new HashMap<String, Object>();
            String pName1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(i));
            List<Summary> summaryList = summaryMapper.getSummaryInfo(checkId, name1Array.getIntValue(i));
            String summaryInfo = JSON.toJSONString(summaryList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray summaryInfoArray = JSONArray.parseArray(summaryInfo);
            for (int j = 0; j < summaryInfoArray.size(); j++) {
                Map<String, Object> part4InnerMap = new HashMap<String, Object>();
                JSONObject part4InnerObject = summaryInfoArray.getJSONObject(j);
                String part4pNname4 = prefixsystemMapper.getName4ByName4Id(part4InnerObject.getIntValue("fourthId"));
                part4InnerMap.put("No", j + 1);
                if (prefixsystemMapper.getFather(prefixsystemMapper.getFather(part4InnerObject.getIntValue("fourthId")).getPreNum()).getPreNum() == 1385) {
                    part4InnerMap.put("pName4", part4pNname4 + "(" + prefixsystemMapper.getFather(prefixsystemMapper.getFather(part4InnerObject.getIntValue("fourthId")).getPreNum()).getParameterName() + ")");
                } else {
                    part4InnerMap.put("pName4", part4pNname4);
                }
                part4InnerMap.put("summary", part4InnerObject.getString("summary"));
                part4InnerList.add(part4InnerMap);
            }
            if (pName1.equals("安全检查")) {
                part4Map.put("name1", "安全");
            } else if (pName1.equals("质量检查")) {
                part4Map.put("name1", "质量");
            } else if (pName1.equals("管理行为")) {
                part4Map.put("name1", "管理行为");
            }
            part4Map.put("part4InnerList", part4InnerList);
            part4List.add(part4Map);
        }
        dataMap.put("part4List", part4List);
        //第二部分 不符合项清单
        List<ProblemCollectDetail> problemList = problemCollectDetailMapper.getAllProblemCollectInfoByCheckId(checkId);
        List<Object> section22List = new ArrayList<Object>();
        for (int p = 0; p < problemList.size(); p++) {
            Map<String, Object> problemListMap = new HashMap<String, Object>();
            problemListMap.put("No", p + 1);
            if (problemList.get(p).getSecondId() == 1385) {
                problemListMap.put("pName4", problemList.get(p).getpName4() + "(" + problemList.get(p).getpName3() + ")");
            } else {
                problemListMap.put("pName4", problemList.get(p).getpName4());
            }
            if (problemList.get(p).getIsRemark().equals("N")) {
                problemListMap.put("problemDescription", problemList.get(p).getProblemDescription());
            } else if (problemList.get(p).getIsRemark().equals("Y")) {
                problemListMap.put("problemDescription", problemList.get(p).getRemark());
            }
            String problemListRiskPoint = "";
            switch (problemList.get(p).getRiskPoint()) {
                case "提醒":
                    problemListRiskPoint = "1";
                    break;
                case "1":
                    problemListRiskPoint = "2";
                    break;
                case "2":
                    problemListRiskPoint = "3";
                    break;
                case "3":
                    problemListRiskPoint = "4";
                    break;
                case "4":
                    problemListRiskPoint = "5";
                    break;
                default:
                    problemListRiskPoint = "";
                    break;
            }
            problemListMap.put("riskPoint", problemListRiskPoint);
            section22List.add(problemListMap);
        }
        dataMap.put("section22List", section22List);

        //第三部分，各部分工程检查情况
        List<Object> section2pName1Info = problemCollectDetailMapper.getAllName1IdForType3Report(checkId, type3List);
        String section2Name1 = JSON.toJSONString(section2pName1Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray section2Name1Array = JSONArray.parseArray(section2Name1);
        String section2pName1 = "";
        List<Object> section2List = new ArrayList<Object>();
        for (int b = 0; b < section2Name1Array.size(); b++) {
            Map<String, Object> section2Name1Map = new HashMap<String, Object>();
            List<Object> section2name1List = new ArrayList<Object>();
            String section2name1 = prefixsystemMapper.getName4ByName4Id(section2Name1Array.getIntValue(b));
            if (section2name1.equals("安全检查")) {
                section2pName1 = "安全问题";
            } else if (section2name1.equals("质量检查")) {
                section2pName1 = "质量问题";
            } else if (section2name1.equals("管理行为")) {
                section2pName1 = "管理体系及管理动作";
            }
            section2Name1Map.put("section2pName1", section2pName1);
            List<Object> section2Name4Info = problemCollectDetailMapper.getAllName4ByName1ForType3(checkId, section2name1, type3List);
            String section2Name44 = JSON.toJSONString(section2Name4Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray section2Name4Array = JSONArray.parseArray(section2Name44);
            for (int w = 0; w < section2Name4Array.size(); w++) {
                Map<String, Object> section2Name4Map = new HashMap<String, Object>();
                List<Object> section2Name4List = new ArrayList<Object>();
                int section2Name4Id = section2Name4Array.getIntValue(w);
                String section2Name4 = prefixsystemMapper.getName4ByName4Id(section2Name4Id);
                List<ProblemCollectDetail> section2Name6Info = problemCollectDetailMapper.getAllName6InfoByName4ForType3(checkId, section2Name4Id, section2name1, type3List);
                String section2Name66 = JSON.toJSONString(section2Name6Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray section2Name6Array = JSONArray.parseArray(section2Name66);
                for (int c = 0; c < section2Name6Array.size(); c++) {
                    Map<String, Object> section2Name6Map = new HashMap<String, Object>();
                    List<Object> picList = new ArrayList<Object>();
                    JSONObject section2Name6Object = section2Name6Array.getJSONObject(c);
                    section2Name6Map.put("section2pName6No", c + 1);
                    section2Name6Map.put("section2pName6", section2Name6Object.getString("pName6"));
                    section2Name6Map.put("section2pName5", section2Name6Object.getString("pName5"));
                    String section2RiskPoint = "";
                    switch (section2Name6Object.getString("riskPoint")) {
                        case "2":
                            section2RiskPoint = "3";
                            break;
                        case "3":
                            section2RiskPoint = "4";
                            break;
                        case "4":
                            section2RiskPoint = "5";
                            break;
                        default:
                            section2RiskPoint = "";
                            break;
                    }
                    section2Name6Map.put("section2RiskLevel", section2RiskPoint);
                    section2Name6Map.put("section2CheckPart", section2Name6Object.getString("checkPart"));
                    section2Name6Map.put("section2ProblemNum", section2Name6Object.getString("problemQua"));
                    if (section2Name6Object.getString("isRemark").equals("N")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("problemDescription"));
                    } else if (section2Name6Object.getString("isRemark").equals("Y")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("remark"));
                    }
                    section2Name6Map.put("section2normsProvison", section2Name6Object.getString("normsProvison"));
                    section2Name6Map.put("section2suggestion", section2Name6Object.getString("suggestion"));
                    String section2picPath = section2Name6Object.getString("picPath");
                    String picName = section2Name6Object.getString("picName");
                    JSONArray ja = JSONArray.parseArray(picName);
                    if (ja.size() == 0) {
                        //String s = MDoc.getImageStr("C:\\Users\\96500\\Desktop\\20190329183836002.png");
                        String s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
//                        String s = MDoc.getImageStr("D:\\WAAA\\新建文件夹\\QQ截图20200819114048.jpg");

                        picList.add(s);
                    } else {
                        for (int o = 0; o < ja.size(); o++) {
                            String s="";
                            if("prod".equals(profiles.getActives())){
                                s = MDoc.getImageStr(section2picPath + ja.getString(o));
                            }
//                            String s = MDoc.getImageStr("D:\\WAAA\\新建文件夹\\QQ截图20200819114048.jpg" + ja.getString(o));
                            //String s = MDoc.getImageStr("C:\\Users\\96500\\Desktop\\20190329183836002.png");
                            picList.add(s);
                        }
                    }
                    section2Name6Map.put("picList", picList);
                    section2Name4List.add(section2Name6Map);

                }
                if (prefixsystemMapper.getFather(section2Name4Id).getPreNum() == 1385) {
                    section2Name4Map.put("section2pName4", section2Name4 + "(" + prefixsystemMapper.getFather(section2Name4Id).getParameterName() + ")");
                } else {
                    section2Name4Map.put("section2pName4", section2Name4);
                }
                section2Name4Map.put("section2Name4List", section2Name4List);
                section2name1List.add(section2Name4Map);
            }
            section2Name1Map.put("section2Name1List", section2name1List);
            section2List.add(section2Name1Map);
        }
        dataMap.put("section2List", section2List);
        MDoc mdoc = new MDoc();
        String path = FileUtil.getServerFolderPath();
        File f1 = new File(path, "doc");
        if (!f1.exists()) {
            f1.mkdirs();
        }
//        mdoc.createDoc(dataMap, "D:\\WAAA\\新建文件夹\\" + projectObject.getString("projectName").replace('#','号')+"安全专项报告"+fileName + ".doc", "ftl\\ZJ1.0.ftl");
//        MDoc.docToDocx("D:\\WAAA\\新建文件夹\\" + projectObject.getString("projectName").replace('#','号')+"安全专项报告"+fileName + ".doc", "D:\\WAAA\\新建文件夹\\" + projectObject.getString("projectName").replace('#','号')+"安全专项报告"+fileName + ".doc");
//        String result = "D:\\WAAA\\新建文件夹\\" + projectObject.getString("projectName").replace('#','号')+"安全专项报告"+fileName + ".doc";
        mdoc.createDoc(dataMap, path + "\\doc\\" + projectObject.getString("projectName").replace('#','号')+"安全专项报告"+fileName + ".doc", "ftl\\ZJ1.0.ftl");
        //MDoc.docToDocx("D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + projectObject.getString("projectName").replace('#','号')+"安全专项报告"+fileName + ".doc", "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + projectObject.getString("projectName").replace('#','号')+"安全专项报告"+fileName + ".doc");
        String result = urlProperties.getAddress()+"/doc/" + projectObject.getString("projectName").replace('#','号')+"安全专项报告"+fileName + ".doc";
        return result;
    }

    @Override
    public List<Object> getChooseInfo(int checkId) {
        List<Object> list = new ArrayList<Object>();
        List<Object> pNname1InfoList = problemCollectDetailMapper.getAllName1Id(checkId);
        String pName1Info = JSON.toJSONString(pNname1InfoList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray pNname1InfoArray = JSONArray.parseArray(pName1Info);
        for (int i = 0; i < pNname1InfoArray.size(); i++) {
            List<Object> listName1 = new ArrayList<Object>();
            Map<String, Object> name1Map = new HashMap<String, Object>();
            int firstId = pNname1InfoArray.getIntValue(i);
            String pName1 = prefixsystemMapper.getName4ByName4Id(firstId);
            List<Object> secondIdInfoList = problemCollectDetailMapper.getSecondId(checkId, pName1);
            String secondIdInfo = JSON.toJSONString(secondIdInfoList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray secondIdInfoArray = JSONArray.parseArray(secondIdInfo);
            for (int j = 0; j < secondIdInfoArray.size(); j++) {
                List<Object> listName2 = new ArrayList<Object>();
                Map<String, Object> name2Map = new HashMap<String, Object>();
                int secondId = secondIdInfoArray.getIntValue(j);
                List<Object> thirdIdInfoList = problemCollectDetailMapper.getThirdId(checkId, pName1, secondId);
                String thirdIdInfo = JSON.toJSONString(thirdIdInfoList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray thirdIdInfoArray = JSONArray.parseArray(thirdIdInfo);
                for (int k = 0; k < thirdIdInfoArray.size(); k++) {
                    List<Object> listName3 = new ArrayList<Object>();
                    Map<String, Object> name3Map = new HashMap<String, Object>();
                    int thirdId = thirdIdInfoArray.getIntValue(k);
                    List<Object> fourthIdInfoList = problemCollectDetailMapper.getFourthId(checkId, pName1, secondId, thirdId);
                    String fourthIdInfo = JSON.toJSONString(fourthIdInfoList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray fourthIdInfoArray = JSONArray.parseArray(fourthIdInfo);
                    for (int l = 0; l < fourthIdInfoArray.size(); l++) {
                        Map<String, Object> name4Map = new HashMap<String, Object>();
                        int fourthId = fourthIdInfoArray.getIntValue(l);
                        String pName4 = prefixsystemMapper.getName4ByName4Id(fourthId);
                        name4Map.put("value", fourthId);
                        name4Map.put("label", pName4);
                        listName3.add(name4Map);
                    }
                    String pName3 = prefixsystemMapper.getName4ByName4Id(thirdId);
                    name3Map.put("value", thirdId);
                    name3Map.put("label", pName3);
                    name3Map.put("children", listName3);
                    listName2.add(name3Map);
                }
                String pName2 = prefixsystemMapper.getName4ByName4Id(secondId);
                name2Map.put("value", secondId);
                name2Map.put("label", pName2);
                name2Map.put("children", listName2);
                listName1.add(name2Map);
            }
            name1Map.put("value", firstId);
            name1Map.put("label", pName1);
            name1Map.put("children", listName1);
            list.add(name1Map);
        }
        return list;
    }
    @Override
    public List<Object> getNewChooseInfo(int checkId){
        List<Object> list = new ArrayList<Object>();
        List<Object> pNname1InfoList = newProblemCollectDetailMapper.getAllName1Id(checkId);
        String pName1Info = JSON.toJSONString(pNname1InfoList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray pNname1InfoArray = JSONArray.parseArray(pName1Info);
        for (int i = 0; i < pNname1InfoArray.size(); i++) {
            List<Object> listName1 = new ArrayList<Object>();
            Map<String, Object> name1Map = new HashMap<String, Object>();
            int firstId = pNname1InfoArray.getIntValue(i);
            String pName1 = newprefixsystemMapper.getName4ByName4Id(firstId);
            List<Object> secondIdInfoList = newProblemCollectDetailMapper.getSecondId(checkId, pName1);
            String secondIdInfo = JSON.toJSONString(secondIdInfoList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray secondIdInfoArray = JSONArray.parseArray(secondIdInfo);
            for (int j = 0; j < secondIdInfoArray.size(); j++) {
                List<Object> listName2 = new ArrayList<Object>();
                Map<String, Object> name2Map = new HashMap<String, Object>();
                int secondId = secondIdInfoArray.getIntValue(j);
                List<Object> thirdIdInfoList = newProblemCollectDetailMapper.getThirdId(checkId, pName1, secondId);
                String thirdIdInfo = JSON.toJSONString(thirdIdInfoList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray thirdIdInfoArray = JSONArray.parseArray(thirdIdInfo);
                for (int k = 0; k < thirdIdInfoArray.size(); k++) {
                    List<Object> listName3 = new ArrayList<Object>();
                    Map<String, Object> name3Map = new HashMap<String, Object>();
                    int thirdId = thirdIdInfoArray.getIntValue(k);
                    List<Object> fourthIdInfoList = newProblemCollectDetailMapper.getFourthId(checkId, pName1, secondId, thirdId);
                    String fourthIdInfo = JSON.toJSONString(fourthIdInfoList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray fourthIdInfoArray = JSONArray.parseArray(fourthIdInfo);
                    for (int l = 0; l < fourthIdInfoArray.size(); l++) {
                        Map<String, Object> name4Map = new HashMap<String, Object>();
                        int fourthId = fourthIdInfoArray.getIntValue(l);
                        String pName4 = newprefixsystemMapper.getName4ByName4Id(fourthId);
                        name4Map.put("value", fourthId);
                        name4Map.put("label", pName4);
                        listName3.add(name4Map);
                    }
                    String pName3 = newprefixsystemMapper.getName4ByName4Id(thirdId);
                    name3Map.put("value", thirdId);
                    name3Map.put("label", pName3);
                    name3Map.put("children", listName3);
                    listName2.add(name3Map);
                }
                String pName2 = newprefixsystemMapper.getName4ByName4Id(secondId);
                name2Map.put("value", secondId);
                name2Map.put("label", pName2);
                name2Map.put("children", listName2);
                listName1.add(name2Map);
            }
            name1Map.put("value", firstId);
            name1Map.put("label", pName1);
            name1Map.put("children", listName1);
            list.add(name1Map);
        }
        return list;
    }

    @Override
    public List<? extends Object> getFourthInfo(int checkId, int fourthId) {
        System.out.println("第四级Id：" + fourthId);
        System.out.println("检查Id：" + checkId);
        List<ProblemCollectDetail> problemCollectDetailList = problemCollectDetailMapper.getAllFourthInfo(checkId, fourthId);
        List<ProblemCollectDetail> newProblemCollectDetailList=newProblemCollectDetailMapper.getAllFourthInfo(checkId,fourthId);
        if(problemCollectDetailList.size()!=0){
            return problemCollectDetailList;
        }else {
            return newProblemCollectDetailList;
        }

    }
    @Override
    public Object getContractInfoByPage(int curPage, int pageSize) {
        PageHelper.startPage(curPage, pageSize);
        List<Contractinfo> list = contractinfoMapper.getAllContractUnFinished();
        PageInfo result = new PageInfo(list);
        return result;
    }

    /*
     * @Author wenyihan
     * @Description 通过vague search查询合同信息
     * @Date 9:45 2019/6/20
     * @Param [curPage, pageSize, inputSearch]
     * @return java.lang.Object
     **/
    @Override
    public Object searchContractInfoByPage(int curPage, int pageSize, String inputSearch) {
        PageHelper.startPage(curPage, pageSize);
        List<Contractinfo> list = contractinfoMapper.getContractInfoByInput(inputSearch);
        PageInfo result = new PageInfo(list);
        return result;
    }

    @Override
    public String addContractInfo(Contractinfo contractinfo) {
        try {
            SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
            Date date = new Date(System.currentTimeMillis());
            contractinfo.setNewCreateTime(formatter.format(date));
            contractinfo.setLastEditTime(formatter.format(date));
            contractinfoMapper.insert(contractinfo);
            return "success";
        } catch (Exception e) {
            e.printStackTrace();
            return "error";
        }
    }

    @Override
    public String deleteContractInfo(int contractId) {
        try {
            contractinfoMapper.deleteByPrimaryKey(contractId);
            return "success";
        } catch (Exception e) {
            e.printStackTrace();
            return "error";
        }
    }

    @Override
    public String addPointLimitInfo(Pointlimit pointlimit) {
        try {
            pointlimitMapper.insert(pointlimit);
            return "success";
        } catch (Exception e) {
            e.printStackTrace();
            return "error";
        }
    }

    @Override
    public String editPointLimitInfo(Pointlimit pointlimit) {
        Pointlimit p =pointlimitMapper.selectByPrimaryKey(pointlimit.getMkey());
        System.out.println(pointlimit.getMkey()+"2333333333333333333"+p);
        try {
            pointlimitMapper.updateByPrimaryKey(pointlimit);
            System.out.println(pointlimit+"这是什么东西");
            return "success";
        } catch (Exception e) {
            e.printStackTrace();
            return "error";
        }
    }

    @Override
    public String deletePointLimitInfo(Integer mkey) {

            try {
                System.out.println(pointlimitMapper.selectByPrimaryKey(mkey)+"现在还没有执行"+mkey);
                pointlimitMapper.deleteByPrimaryKey(mkey);
                System.out.println(pointlimitMapper.selectByPrimaryKey(mkey)+"方法已经执行啦");
                return "success";
            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("SHIBAI啦");
                return "error";
            }


    }

    @Override
    public String deleteCheckInfo(int checkId) {
        try {
            contractchecktaskMapper.deleteByPrimaryKey(checkId);
            return "success";
        } catch (Exception e) {
            e.printStackTrace();
            return "error";
        }
    }

    @Override
    public Object getLimitPoint(int curPage, int pageSize) {

        PageHelper.startPage(curPage, pageSize);

        List<Pointlimit> list = pointlimitMapper.selectAll();
        PageInfo result = new PageInfo(list);
        return result;

    }

    @Override
    public Object getTest(Integer equipId) {
        System.out.println("测试访问");
        return equipinfoMapper.selectByPrimaryKey(equipId);
    }

    @Override
    public List<Object> getClientByType(String clientType) {
        return contractinfoMapper.getClientByType(clientType);
    }

    @Override
    public String saveCheckResultEdit(int mkey, int fifthId,int sixthId, String riskPoint, String suggestion, String picName) {
        try {
            Problemcollect problemcollect = new Problemcollect();
            SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
            Date date = new Date(System.currentTimeMillis());
            problemcollect.setLastEditTime(formatter.format(date));
            problemcollect.setMkey(mkey);
            problemcollect.setFifthId(fifthId);
            problemcollect.setSixthId(sixthId);
            problemcollect.setRiskPoint(riskPoint);
            problemcollect.setSuggestion(suggestion);
            problemcollect.setPicName(picName);
            problemcollectMapper.updateByPrimaryKeySelective(problemcollect);
            return "success";
        } catch (Exception e) {
            e.printStackTrace();
            return "error";
        }
    }

    @Override
    public String saveBack(int checkId) {
        try {
            ContractCheckTask contractchecktask = new ContractCheckTask();
            SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
            Date date = new Date(System.currentTimeMillis());
            contractchecktask.setLastEditTime(formatter.format(date));
            contractchecktask.setCheckId(checkId);
            contractchecktask.setIsFinish("N");
            contractchecktaskMapper.updateByPrimaryKeySelective(contractchecktask);
            return "success";
        } catch (Exception e) {
            e.printStackTrace();
            return "error";
        }
    }

    @Override
    public String uploadReport(int checkId, String docxName) {
        try {
            ContractCheckTask contractchecktask = new ContractCheckTask();
            SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
            Date date = new Date(System.currentTimeMillis());
            contractchecktask.setLastEditTime(formatter.format(date));
            contractchecktask.setCheckId(checkId);
            contractchecktask.setSummaryReport(docxName);
            contractchecktaskMapper.updateByPrimaryKeySelective(contractchecktask);
            return "success";
        } catch (Exception e) {
            e.printStackTrace();
            return "error1";
        }
    }

    @Override
    public String getDownLoadUrlByCheckId(int checkId) {
        String result = (contractchecktaskMapper.getDownloadNameByCheckId(checkId) == "" ||
                contractchecktaskMapper.getDownloadNameByCheckId(checkId) == null) ? "error" :
                urlProperties.getAddress()+"/upload/docx/" + contractchecktaskMapper.getDownloadNameByCheckId(checkId);
        //String result = (contractchecktaskMapper.getDownloadNameByCheckId(checkId) == "" || contractchecktaskMapper.getDownloadNameByCheckId(checkId) == null) ? "error" : "http://localhost:8080/docx/" + contractchecktaskMapper.getDownloadNameByCheckId(checkId) + ".doc";
        return result;
    }

    @Override
    public String deleteProblemCollect(int mkey) {
        try {
            problemcollectMapper.deleteByPrimaryKey(mkey);
            return "success";
        } catch (Exception e) {
            e.printStackTrace();
            return "error";
        }
    }

    @Override
    public Object getUncheckInfo(int fourthId, int checkId) {
        List<Object> list = new ArrayList<>();
        Map<String, Object> map = new HashMap<String, Object>();
        List<Object> uncheckedList = new ArrayList<Object>();
        List<Integer> wsjList = prefixsystemMapper.getWSJList(checkId, fourthId);
        for (int j = 0; j < wsjList.size(); j++) {
            Map<String, Object> map1 = new HashMap<String, Object>();
            String unCheckedpName6 = prefixsystemMapper.getName4ByName4Id(wsjList.get(j));
            int unCheckedFifthId = prefixsystemMapper.getFather(wsjList.get(j)).getPreNum();
            String unCheckedpName5 = prefixsystemMapper.getName4ByName4Id(unCheckedFifthId);
            map1.put("pName56", unCheckedpName6 + "(" + unCheckedpName5 + ")");
            map1.put("point", prefixsystemMapper.getPoint4ByPoint4Id(wsjList.get(j)));
            map1.put("type", "未涉及问题");
            uncheckedList.add(map1);
        }
        List<Uncheckeditems> uncheckeditemsList = uncheckeditemsMapper.getAllUncheckedInfoByFourthId(checkId, fourthId);
        for (int i = 0; i < uncheckeditemsList.size(); i++) {
            Map<String, Object> map2 = new HashMap<String, Object>();
            String unCheckedpName6 = prefixsystemMapper.getName4ByName4Id(uncheckeditemsList.get(i).getSixthId());
            int unCheckedFifthId = prefixsystemMapper.getFather(uncheckeditemsList.get(i).getSixthId()).getPreNum();
            String unCheckedpName5 = prefixsystemMapper.getName4ByName4Id(unCheckedFifthId);
            map2.put("pName56", unCheckedpName6 + "(" + unCheckedpName5 + ")");
            map2.put("point", prefixsystemMapper.getPoint4ByPoint4Id(uncheckeditemsList.get(i).getSixthId()));
            map2.put("type", "没有问题");
            uncheckedList.add(map2);
        }
        //获取应得分数，实得分数和最终得分
        List<ProblemCollectDetail> sixthPoints = problemCollectDetailMapper.getsixthPoints(checkId, fourthId);
        String pointName6Info = JSON.toJSONString(sixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray sixthPointsArray = JSONArray.parseArray(pointName6Info);
        double calculatePoint6 = 0;
        double calculatePoint66 = 0;
        double calculateTruePoint = 0;
        for (int y = 0; y < sixthPointsArray.size(); y++) {
            JSONObject sixPointObject = sixthPointsArray.getJSONObject(y);
            int deductSixthId = sixPointObject.getIntValue("sixthId");
            float deductPointsSumFloat = problemCollectDetailMapper.getdeductSum(checkId, deductSixthId);
            double deductPointsSum = Double.valueOf(String.valueOf(deductPointsSumFloat));
            double truePoint = Double.parseDouble(sixPointObject.getString("point6"));
            if (truePoint <= deductPointsSum) {
                calculatePoint66 = 0;
            } else {
                calculatePoint66 = truePoint - deductPointsSum;
            }
            calculateTruePoint += truePoint;
            calculatePoint6 += calculatePoint66;
        }
        double noProblemPoint = 0;
        List<Object> noProblemSixthIdList = uncheckeditemsMapper.getNoProblemSixthId(checkId, fourthId);
        String noProblemSixthIdInfo = JSON.toJSONString(noProblemSixthIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray noProblemSixthArray = JSONArray.parseArray(noProblemSixthIdInfo);
        for (int m = 0; m < noProblemSixthArray.size(); m++) {
            int noProblemSixthId = noProblemSixthArray.getIntValue(m);
            double noProblem = Double.parseDouble(prefixsystemMapper.getPoint4ByPoint4Id(noProblemSixthId));
            noProblemPoint += noProblem;
        }
        System.out.println("第六级扣过的分数总分:" + calculatePoint6 + "没有问题的总分:" + noProblemPoint + "第六级总分:" + calculateTruePoint);
        double checkItemPoint = (calculatePoint6 + noProblemPoint) / (calculateTruePoint + noProblemPoint) * 100;
        List<ProblemCollectDetail> checkItemCalcuList = problemCollectDetailMapper.getAllFourthInfo(checkId, fourthId);
        String maxFourthRiskPoint = pointsCalculate.getMaxRiskPoint(checkItemCalcuList);
        int maxFourthRiskPointNum = problemCollectDetailMapper.getRiskPointCount(checkId, fourthId, maxFourthRiskPoint);
        double limitFourhPoint = Double.parseDouble((pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint)) == null ? "100" : pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint));
        if (checkItemPoint > limitFourhPoint) {
            checkItemPoint = limitFourhPoint;
        }
        DecimalFormat df = new DecimalFormat("0.00");
        String fourthPoint = df.format(checkItemPoint);
        String ideaPoint = df.format(calculateTruePoint + noProblemPoint);
        String realPoint = df.format(calculatePoint6 + noProblemPoint);
        map.put("fourthPoint", fourthPoint);
        map.put("ideaPoint", ideaPoint);
        map.put("realPoint", realPoint);
        map.put("pName4", prefixsystemMapper.getName4ByName4Id(fourthId));
        map.put("unCheckedList", uncheckedList);
        list.add(map);
        return list;
    }

    @Override
    public List<Object> findAllInfo(Integer checkId) {
        List<Object> list = contractchecktaskMapper.findAllInfo(checkId);
        return list;
    }
    //返回examineInfo中table的信息，包括PCD表和检查人（userName）
    @Override
    public List<PCDandUSERNAME> findPCDInfo(Integer checkId, Integer fourthId) {
        List<PCDandUSERNAME> list = contractchecktaskMapper.findPCDInfo(checkId, fourthId);
        return list;
    }

    @Override
    public Object examineProblem(Integer checkId) {
        try{
            ContractCheckTask contractchecktask = new ContractCheckTask();
            SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
            Date date = new Date(System.currentTimeMillis());
            contractchecktask.setLastEditTime(formatter.format(date));
            contractchecktask.setCheckId(checkId);
            contractchecktask.setIsExamine("Y");
            contractchecktaskMapper.updateByPrimaryKeySelective(contractchecktask);
            return "success";
        }catch (Exception e){
            return e;
        }
    }

    @Override
    public Object qualifyExamine(Integer checkId) {
        Integer obj =  contractchecktaskMapper.qualifyExamine(checkId);
        if (obj == 0){
            return "success";
        }else{
            return "error";
        }
    }

    //返回examineInfo中第二级collapse中显示的第四级名称
    @Override
    public List<Node4PName1VO> Getnode4nameBycheckId(Integer checkId){
        List<Node4PName1VO> node4name = contractchecktaskMapper.Getnode4nameBycheckId(checkId);
        node4name.stream()
                .sorted(Comparator.comparing(Node4PName1VO::getFirstId))
                .collect(Collectors.toList());
        return node4name;

    }

    @Override
    public List<Summary> getSummary(Integer checkId, Integer fourthId) {
        return summaryMapper.getSummaryInfoByFourthId(checkId, fourthId);
    }

    @Override
    public List<Prefixsystem> findSixthName(Integer fourthId) {
        List<Prefixsystem> list = prefixsystemMapper.getSixthNameByFourthId(fourthId);
        return list;
    }

    @Override
    public List<Newproblemdescription> findProblemDesBySixthId(Integer sixthId) {
        return newproblemdescriptionMapper.getLastLevel(sixthId);
    }

    @Override
    public List<ProblemNumVO> findProblemNumByLastId(Integer lastId) {
        List<ProblemNumVO> list = new ArrayList<>();
        String problemNum = "";
        int size = 1;

        List<Newproblemdescription> all = newproblemdescriptionMapper.findAllByNumber(lastId);
        for (Newproblemdescription npd: all) {
            problemNum = npd.getProblemNum();
            for (int i = 0; i < problemNum.length(); i++){
                if(problemNum.charAt(i) == ';'){
                    size++;
                }
            }
        }
        String[] problemArray = new String[size];
        problemArray = problemNum.split(";");

        for (int i = 0; i < problemArray.length; i++){
            ProblemNumVO problemNumVO = new ProblemNumVO(i+1, problemArray[i]);
            list.add(problemNumVO);
        }
        return list;
    }

    @Override
    public boolean problemCollectUpdate(Integer mkey, Integer fifthId, Integer sixthId, String remark, String suggestion, String problemQua, String picName, String checkPart, Integer lastId) {
        Problemcollect pc = new Problemcollect(mkey, fifthId, sixthId, lastId, picName, checkPart, remark, suggestion, problemQua);

        int isSuccess = problemcollectMapper.updateByPrimaryKeySelective(pc);
        if (isSuccess == 1){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public boolean newProblemDesUpdate(Integer number, String riskNumber) {
        Newproblemdescription npd = new Newproblemdescription(number, riskNumber);
        int isSuccess = newproblemdescriptionMapper.updateByPrimaryKeySelective(npd);
        if (isSuccess == 1){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public boolean corrspondScaleUpdate(Integer mkey, Integer lastId, String correspondScale) {
        int pnSize = 0, prSize = 0, riskNumber = 0;
        String riskPoint = "";

        String pcProblemQua = problemcollectMapper.findProblemQuaByMkeyAndLastId(mkey, lastId);
        List<Newproblemdescription> npdList = newproblemdescriptionMapper.findAllByNumber(lastId);

        for (Newproblemdescription npd: npdList) {
            String problemNum = npd.getProblemNum();
            pnSize = getSize(problemNum);

            String problemRn = npd.getProblemRn();
            prSize = getSize(problemRn);
            //获取riskNumber
            riskNumber = Integer.parseInt(npd.getRiskNumber());
        }
        //分割problemNum problemRn
        String []problemNumArray = new String[pnSize];
        String []problemRnArray = new String[prSize];
        for (Newproblemdescription npd: npdList) {
            String problemNum = npd.getProblemNum();
            String problemRn = npd.getProblemRn();
            problemNumArray = problemNum.split(";");
            problemRnArray = problemRn.split(";");
        }
        //字符串比较
        List<String> problemNumList = Arrays.asList(problemNumArray);
        int[] indexArray = ListUtil.indexOfAll(problemNumList, pcProblemQua::equals);
        //取出Rn
        Double Rn = Double.parseDouble(problemRnArray[indexArray[0]]);
        //计算l
        Double L = Integer.parseInt(correspondScale) * Rn * riskNumber;
        if (24 < L){
            riskPoint = "4";
        }else if ( 12 < L && L <= 24){
            riskPoint = "3";
        }else if ( 4 < L && L <= 12){
            riskPoint = "2";
        }else if ( L <= 4){
            riskPoint = "1";
        }

        Problemcollect pc = new Problemcollect(mkey, riskPoint);
        int isPcUpdateSuccess = problemcollectMapper.updateByPrimaryKeySelective(pc);

        Problemcollect pcUpdateCorrespondScale = new Problemcollect();
        pcUpdateCorrespondScale.setLastId(lastId);
        pcUpdateCorrespondScale.setCorrespondScale(correspondScale);
        int isPcUpdateCorSuccess = problemcollectMapper.updateByPrimaryKeySelective(pcUpdateCorrespondScale);

        if (isPcUpdateSuccess == 1 && isPcUpdateCorSuccess == 1){
            return true;
        }else{
            return false;
        }
    }

    public Integer getSize(String str){
        int count = 1;
        for (Character ch: str.toCharArray()) {
            if (ch.equals(';')){
                count++;
            }
        }
        return count;
    }

    @Override
    public List<PCDandUSERNAME> findPCDInfoAfterUpdate(Integer checkId, Integer fourthId) {
        List<PCDandUSERNAME> list = contractchecktaskMapper.findPCDInfoAfterUpdate(checkId, fourthId);
        return list;
    }

    @Override
    public String saveEditInfo(int mkey, String riskPoint, String suggestion, String picName) {
        Problemcollect problemcollect = problemcollectMapper.selectByPrimaryKey(mkey);
        if(null!=problemcollect){
            problemcollect.setRiskPoint(riskPoint);
            problemcollect.setSuggestion(suggestion);
            problemcollect.setPicName(picName);
            problemcollectMapper.updateByPrimaryKeySelective(problemcollect);
            return "success";
        }
        return "error";
    }

    /**
     * @author： wenyihan
     * @description：判断新老体系，新体系返回true、老体系返回false
     * @date： 20:16 2020/12/13
     * @param： [checkId]
     * @return： java.lang.Boolean
    */
    @Override
    public Boolean judgeNewOrOldSystem(int checkId) {
        int problemNum = problemcollectMapper.selectProblemNumByCheckId(checkId);
        if (problemNum == 0){
            return false;
        }else{
            return true;
        }
    }

    /**
     * @author： wenyihan
     * @description：通过fourthID获取第五级名称+number
     * @date： 23:44 2020/12/15
     * @param： [fourthId]
     * @return： java.util.List<com.whut.v_vo.oldSysPreListVO>
    */
    @Override
    public List<oldSysPreListVO> getpNameByUpperId(int preNum) {
        List<oldSysPreListVO> pName5List = prefixsystemMapper.getpNameByUpperId(preNum);
        return pName5List;
    }

    /**
     * @author： wenyihan
     * @description：通过上级id找到最后一级的pd，np，pn
     * @date： 12:58 2020/12/17
     * @param： [preNum]
     * @return： java.util.List<com.whut.v_vo.oldSysLastListVO>
     */
    @Override
    public List<oldSysLastListVO> getLastListByUpperId(int preNum) {
        List<oldSysLastListVO> lastList = problemdescriptionMapper.getLastListByUpperId(preNum);
        return lastList;
    }

    /**
     * @author： wenyihan
     * @description：//TODO
     * @date： 19:44 2020/12/17
     * @param： [mKey, fifthId, sixthId, lastId, problemQua, suggestion, pic]
     * @return： java.lang.Boolean
    */
    @Override
    public Boolean oldSysUpdate(Integer mKey, Integer fifthId, Integer sixthId, Integer lastId, String problemQua, String suggestion, String pic, String riskPoint) {
        //更新pc表
        Problemcollect problemcollect = new Problemcollect();
        problemcollect.setMkey(mKey);
        problemcollect.setFifthId(fifthId);
        problemcollect.setSixthId(sixthId);
        problemcollect.setLastId(lastId);
        problemcollect.setPicName(pic);
        problemcollect.setSuggestion(suggestion);
        problemcollect.setProblemQua(problemQua);
        problemcollect.setRiskPoint(riskPoint);
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
        format.setTimeZone(TimeZone.getTimeZone("CST"));
        problemcollect.setLastEditTime(format.format(new Date()));

        int pcUpdate = problemcollectMapper.updateByPrimaryKeySelective(problemcollect);
        System.out.println(pcUpdate);
        return pcUpdate != 0;
    }

    @Override
    public String calculateRiskPoint(Integer lastId, String problemQua) {
        //根据新的problemQua获取新的riskPoint
        String riskPoint = "";
        List<Problemdescription> lastList = problemdescriptionMapper.getLastListByLastId(lastId);
        String problemNumTemp = "";
        String riskPointTemp = "";
        for (Problemdescription pd: lastList) {
            problemNumTemp = pd.getProblemNum();
            riskPointTemp = pd.getRiskLevel();
        }
        String[] problemNumArray = problemNumTemp.split(";");
        String[] riskPointArray = riskPointTemp.split(";");
        for (int i = 0; i < problemNumArray.length; i++){
            if(problemNumArray[i].equals(problemQua)){
                riskPoint = riskPointArray[i];
            }
        }
        return riskPoint;
    }

    @Override
    public String editSummary(Integer mKey, String summary) {
        Summary s = new Summary();
        s.setMkey(mKey);
        s.setSummary(summary);
        int res = summaryMapper.updateByPrimaryKey(s);
        if (res == 0){
            return "false";
        }else{
            return "success";
        }
    }

    @Override
    public String insertSummary(Integer checkId, Integer fourthId, String summary, Integer firstId) {
        Summary s = new Summary(checkId, fourthId, "Y", summary, firstId);
        int res = summaryMapper.insertSelective(s);
        if (res == 0){
            return "false";
        }else{
            return "success";
        }
    }

    @Override
    public List<oldSysExamInfoVO> getOldSysFourthInfo(Integer checkId, Integer fourthId) {
        List<oldSysExamInfoVO> list = problemCollectDetailMapper.getOldSysFourthInfo(checkId, fourthId);
        return list;
    }

    @Override
    public String  newHiddenCheckReport(int projectId, int checkId) throws UnsupportedEncodingException {
        StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
        //设置标题字体
        standardChartTheme.setExtraLargeFont(new Font("隶书", Font.BOLD, 20));
        //设置图例的字体
        standardChartTheme.setRegularFont(new Font("宋书", Font.PLAIN, 15));
        //设置轴向的字体
        standardChartTheme.setLargeFont(new Font("宋书", Font.PLAIN, 15));
        //应用主题样式
        DecimalFormat df = new DecimalFormat("0.00");
        int width = 718;
        int height = 468;
        ChartFactory.setChartTheme(standardChartTheme);
        Map<String, Object> dataMap = new HashMap<String, Object>();
        Date date = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        DateFormat d2 = new SimpleDateFormat("yyyy");
        DateFormat d3 = new SimpleDateFormat("MM");
        DateFormat d4 = new SimpleDateFormat("dd");
        String day = d4.format(date);
        String month = d3.format(date);
        String year = d2.format(date);
        String fileName = d1.format(date);
        String zlWeight = prefixsystemMapper.getWeight1ByName1("质量检查");
        String aqWeight = prefixsystemMapper.getWeight1ByName1("安全检查");
        String glWeight = prefixsystemMapper.getWeight1ByName1("管理行为");
        dataMap.put("zlWeight", zlWeight);
        dataMap.put("aqWeight", aqWeight);
        dataMap.put("glWeight", glWeight);
        dataMap.put("day", day);
        dataMap.put("month", month);
        dataMap.put("year", year);
        dataMap.put("zlPoint", "\\");
        DefaultPieDataset datasetPie = new DefaultPieDataset();
        DefaultCategoryDataset datasetBar = new DefaultCategoryDataset();
        final String Bar = "各检查分项";
        //工程概况部分，来自ctp的工程信息
        List<ContractTaskProject> projectList = contracttaskprojectMapper.selectAllByCheckId(projectId);
        String project = JSON.toJSONString(projectList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        System.out.println(project);
        JSONArray projectArray = JSONArray.parseArray(project);
        JSONObject projectObject = projectArray.getJSONObject(0);
        dataMap.put("projectName", projectObject.getString("projectName"));
        dataMap.put("projectAddress", projectObject.getString("area"));
        dataMap.put("jsUnit", projectObject.getString("jsUnit"));
        dataMap.put("jlUnit", projectObject.getString("jlUnit"));
        dataMap.put("sgUnit", projectObject.getString("sgUnit"));
        dataMap.put("projectType", projectObject.getString("projectType"));
        dataMap.put("projectPrice", projectObject.getString("projectPrice"));
        dataMap.put("dangerItem", projectObject.getString("dangerItem"));
        dataMap.put("remark", projectObject.getString("remark"));
        dataMap.put("projectDescription", projectObject.getString("projectDescription"));
        String js = projectObject.getString("jsUniter");
        String jl = projectObject.getString("jlUniter");
        String sg = projectObject.getString("manager");
        dataMap.put("jsUniter", js);
        dataMap.put("jlUniter", jl);
        dataMap.put("sgUniter", sg);
        //工程概况部分，来自设备信息表的设备信息部分
        List<Equipinfo> equipinfoList = equipinfoMapper.getAllByProjectId(projectId);
        String equip = JSON.toJSONString(equipinfoList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray equipArray = JSONArray.parseArray(equip);
        List<Object> equipList = new ArrayList<Object>();
        if (equipArray.size() == 0) {
            Map<String, Object> eqMap = new HashMap<String, Object>();
            eqMap.put("equipType", "\\");
            eqMap.put("equipQua", "\\");
            eqMap.put("equipNum", "\\");
            eqMap.put("equipLeaseUnit", "\\");
            eqMap.put("equipUseUnit", "\\");
            eqMap.put("demolitionUnit", "\\");
            eqMap.put("testUnit", "\\");
            equipList.add(eqMap);
        } else {
            for (int i = 0; i < equipArray.size(); i++) {
                Map<String, Object> eqMap = new HashMap<String, Object>();
                JSONObject equipObject = equipArray.getJSONObject(i);
                eqMap.put("equipType", equipObject.getString("equipType"));
                eqMap.put("equipQua", equipObject.getString("equipQua"));
                eqMap.put("equipNum", equipObject.getString("equipNum"));
                eqMap.put("equipLeaseUnit", equipObject.getString("equipLeaseUnit"));
                eqMap.put("equipUseUnit", equipObject.getString("equipUseUnit"));
                eqMap.put("demolitionUnit", equipObject.getString("demolitionUnit"));
                eqMap.put("testUnit", equipObject.getString("testUnit"));
                equipList.add(eqMap);
            }
        }
        dataMap.put("equipList", equipList);


        //第一部分，（二）分项评估结果 改！
        List<Object> pName1Info = problemCollectDetailMapper.getAllName1Id(checkId);
        String name1 = JSON.toJSONString(pName1Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray name1Array = JSONArray.parseArray(name1);   //firstId

        //安全文明评估结果
        List<Newfuzzyresult> fuzzyInfo = newfuzzyresultMapper.getNewFuzzyInfoByCheckId(checkId, 4);
        List<Object> part2InnerList = new ArrayList<>();
        for (Newfuzzyresult nfz: fuzzyInfo) {
            Map<String, Object> part2InnerMap = new HashMap<>();
            String pName4 = prefixsystemMapper.getName4ByName4Id(nfz.getItemId());
            part2InnerMap.put("pName4", pName4);
            DecimalFormat df1=new DecimalFormat("#.##");
            part2InnerMap.put("checkItemPoint", df1.format(nfz.getPoint()));
            String weight4 = "";
            switch(nfz.getResult()){
                case 0 :
                    weight4 = "可忽略风险";
                    break;
                case 1 :
                    weight4 = "可容忍风险";
                    break;
                case 2 :
                    weight4 = "可接受风险";
                    break;
                case 3 :
                    weight4 = "不可接受风险";
                    break;
                case 4 :
                    weight4 = "拒绝接受风险";
                    break;
            }
            part2InnerMap.put("weight4", weight4);
            part2InnerList.add(part2InnerMap);
        }
        List<Newfuzzyresult> newFuzzySumList = newfuzzyresultMapper.getNewFuzzyInfoByCheckId(checkId, 1);
        dataMap.put("part2InnerList", part2InnerList);
        dataMap.put("aqPoint", newFuzzySumList.get(0).getPoint());
        dataMap.put("checkItemPoint", newFuzzySumList.get(0).getPoint());
        String aqWeight4 = "";
        switch(newFuzzySumList.get(0).getResult()){
            case 0 :
                aqWeight4 = "可忽略风险";
                break;
            case 1 :
                aqWeight4 = "可容忍风险";
                break;
            case 2 :
                aqWeight4 = "可接受风险";
                break;
            case 3 :
                aqWeight4 = "不可接受风险";
                break;
            case 4 :
                aqWeight4 = "拒绝接受风险";
                break;
        }
        dataMap.put("weight4", aqWeight4);


        //安全管理评估结果
        List<newHiddenReportGLList> pName6Info = problemCollectDetailMapper.getAllGLInfoByCheckId(checkId);
        List<Object> part2glList = new ArrayList<>();
        int glIndex = 1;
        double glAllCheckPoint = 0.0;
        //有问题项
        for (newHiddenReportGLList nhr: pName6Info) {
            Map<String, Object> part2glMap = new HashMap<>();
            part2glMap.put("glIndex", glIndex);
            part2glMap.put("glPName6", nhr.getpName6());
            double glPoint6 = Double.parseDouble(nhr.getPoint6());
            for (ReducePoint rp: nhr.getReducePointList()) {
                glPoint6 -= Double.parseDouble(rp.getReducePoint());
            }
            part2glMap.put("glPoint6", glPoint6 < 0? 0 : glPoint6);
            glAllCheckPoint += glPoint6 < 0? 0 : glPoint6;
            part2glList.add(part2glMap);
            glIndex++;
        }
        //无问题项
        List<UncheckSysPoint> noProblemList = uncheckSysPointMapper.getInfoByCheckId(checkId);
        for (UncheckSysPoint usp: noProblemList) {
            Map<String, Object> part2glMap = new HashMap<>();
            part2glMap.put("glIndex", glIndex);
            part2glMap.put("glPName6", usp.getpName6());
            part2glMap.put("glPoint6", usp.getPoint6());
            glIndex++;
            glAllCheckPoint += Double.parseDouble(usp.getPoint6());
            part2glList.add(part2glMap);
        }
        dataMap.put("glAllCheckPoint", glAllCheckPoint);
        dataMap.put("glIndexAll", glIndex);
        dataMap.put("glPoint", glAllCheckPoint);
        dataMap.put("part2glList", part2glList);
        //备注：综合评分=安全文明风险评分*90%+管理行为评分*10%
        double newOverAllPoint = newFuzzySumList.get(0).getPoint()*0.9+glAllCheckPoint*0.1;
        dataMap.put("overAllPoint", newOverAllPoint);



        //第一部分，（三）各个专业问题的分布情况
        List<Object> pName4Info = problemCollectDetailMapper.getAllName4(checkId);
        int allProblemNum = problemCollectDetailMapper.getAllNum(checkId);
        dataMap.put("allProblemNum", allProblemNum);
        String name4 = JSON.toJSONString(pName4Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray name4Array = JSONArray.parseArray(name4);
        List<Object> part3List = new ArrayList<Object>();
        for (int m = 0; m < name4Array.size(); m++) {
            Map<String, Object> part3Map = new HashMap<String, Object>();
            int pName4Id = name4Array.getIntValue(m);
            String pName4 = prefixsystemMapper.getName4ByName4Id(pName4Id);
            int name4Num = problemCollectDetailMapper.countName4(pName4Id, checkId);
            String percent = pointsCalculate.caculateToPercent(name4Num, allProblemNum);
            part3Map.put("No", m + 1);
            part3Map.put("name4", pName4);
            part3Map.put("problemNum", name4Num);
            part3Map.put("percent", percent);
            datasetPie.setValue(pName4 + ":" + percent, new Double(name4Num));
            datasetBar.addValue(name4Num, Bar, pName4);
            part3List.add(part3Map);
        }
        dataMap.put("part3List", part3List);

        //第一部分，三.检查问题综述

        List<Object> partProblemList = new ArrayList<Object>();
        for (int i = 0; i < name1Array.size(); i++) {
            List<Object> partProblemName1List = new ArrayList<Object>();
            Map<String, Object> partProblemMap = new HashMap<String, Object>();
            String pName1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(i));
            List<Object> problemName4List = problemCollectDetailMapper.getAllName4ByName1(checkId, pName1);
            String problemName4Info = JSON.toJSONString(problemName4List, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray problemName4Array = JSONArray.parseArray(problemName4Info);
            for (int k = 0; k < problemName4Array.size(); k++) {
                List<ProblemCollectDetail> partProblemDetailList = problemCollectDetailMapper.getAllFourthInfo(checkId, problemName4Array.getIntValue(k));
                String partProblemDetailInfo = JSON.toJSONString(partProblemDetailList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray partProblemDetailArray = JSONArray.parseArray(partProblemDetailInfo);
                String problemName4 = prefixsystemMapper.getName4ByName4Id(problemName4Array.getIntValue(k));
                for (int j = 0; j < partProblemDetailArray.size(); j++) {
                    Map<String, Object> partProblemName1Map = new HashMap<String, Object>();
                    JSONObject partProblemObject = partProblemDetailArray.getJSONObject(j);
                    String problemDescription = partProblemObject.getString("problemDescription");
                    String riskPoint = partProblemObject.getString("riskPoint");
                    if (partProblemObject.getString("isRemark").equals("N")) {
                        partProblemName1Map.put("problemDescription", problemDescription);
                    } else if (partProblemObject.getString("isRemark").equals("Y")) {
                        partProblemName1Map.put("problemDescription", partProblemObject.getString("remark"));
                    }
                    partProblemName1Map.put("riskPoint", riskPoint);
                    partProblemName1Map.put("name4", problemName4);
                    partProblemName1List.add(partProblemName1Map);
                }
            }
            if (pName1.equals("安全检查")) {
                partProblemMap.put("name1", "安全");
            } else if (pName1.equals("质量检查")) {
                partProblemMap.put("name1", "质量");
            } else if (pName1.equals("管理行为")) {
                partProblemMap.put("name1", "管理行为");
            }
            partProblemMap.put("partProblemName1List", partProblemName1List);
            partProblemList.add(partProblemMap);
        }
        dataMap.put("partProblemList", partProblemList);
        int txNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "提醒");
        int oneNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "1");
        int twoNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "2");
        int threeNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "3");
        int fourNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "4");
        dataMap.put("txNum", txNum);
        dataMap.put("oneNum", oneNum);
        dataMap.put("twoNum", twoNum);
        dataMap.put("threeNum", threeNum);
        dataMap.put("fourNum", fourNum);
        String txPercent = pointsCalculate.caculateToPercent(txNum, allProblemNum);
        String onePercent = pointsCalculate.caculateToPercent(oneNum, allProblemNum);
        String twoPercent = pointsCalculate.caculateToPercent(twoNum, allProblemNum);
        String threePercent = pointsCalculate.caculateToPercent(threeNum, allProblemNum);
        String fourPercent = pointsCalculate.caculateToPercent(fourNum, allProblemNum);
        String txAndOnePercent = pointsCalculate.caculateToPercent(txNum + oneNum, allProblemNum);
        dataMap.put("txPercent", txPercent);
        dataMap.put("onePercent", onePercent);
        dataMap.put("twoPercent", twoPercent);
        dataMap.put("threePercent", threePercent);
        dataMap.put("fourPercent", fourPercent);
        DefaultPieDataset datasetRiskPie = new DefaultPieDataset();
        DefaultCategoryDataset datasetRiskBar = new DefaultCategoryDataset();
        datasetRiskPie.setValue("特征值1" + ":" + txAndOnePercent, new Double(txNum + oneNum));
        datasetRiskPie.setValue("特征值2" + ":" + twoPercent, new Double(twoNum));
        datasetRiskPie.setValue("特征值3" + ":" + threePercent, new Double(threeNum));
        datasetRiskPie.setValue("特征值4" + ":" + fourPercent, new Double(fourNum));
        final String flag1 = "特征值1";
        final String flag2 = "特征值2";
        final String flag3 = "特征值3";
        final String flag4 = "特征值4";
        final String riskBar = "特征值情况统计";
        datasetRiskBar.addValue(txNum + oneNum, flag1, riskBar);
        datasetRiskBar.addValue(twoNum, flag2, riskBar);
        datasetRiskBar.addValue(threeNum, flag3, riskBar);
        datasetRiskBar.addValue(fourNum, flag4, riskBar);
        try {
            JFreeChart chart = ChartFactory.createPieChart("隐患分布饼图", datasetRiskPie, true, true, false);
            final PiePlot plot = (PiePlot) chart.getPlot();
            plot.setStartAngle(0);
            plot.setForegroundAlpha(0.90f);
            plot.setInteriorGap(0.02);
            chart.getLegend().setVisible(false);
            plot.setSectionPaint("特征值1" + ":" + txAndOnePercent, new Color(49, 95, 232));
            plot.setSectionPaint("特征值2" + ":" + twoPercent, new Color(232, 232, 49));
            plot.setSectionPaint("特征值3" + ":" + threePercent, new Color(240, 117, 60));
            plot.setSectionPaint("特征值4" + ":" + fourPercent, new Color(232, 36, 18));
            //File pieChart = new File("C:\\Users\\96500\\Desktop\\test\\" + fileName + "RiskpieChart.png");
            File pieChart = new File(IMG_PATH + fileName + "RiskpieChart.png");
            //File pieChart = new File("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "RiskpieChart.png");
            ChartUtils.saveChartAsPNG(pieChart, chart, width, height);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            JFreeChart barChart = ChartFactory.createBarChart("隐患分布直方图",
                    "",
                    "数量",
                    datasetRiskBar,
                    PlotOrientation.VERTICAL,
                    true, true, false);
            CategoryPlot plot = (CategoryPlot) barChart.getPlot();
            plot.getRenderer().setSeriesPaint(0, new Color(49, 95, 232));
            plot.getRenderer().setSeriesPaint(1, new Color(232, 232, 49));
            plot.getRenderer().setSeriesPaint(2, new Color(240, 117, 60));
            plot.getRenderer().setSeriesPaint(3, new Color(232, 36, 18));
            BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
            barRenderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
            barRenderer.setDefaultItemLabelsVisible(true);
            barRenderer.setItemLabelAnchorOffset(-20D);
            //File barChartFile = new File("C:\\Users\\96500\\Desktop\\test\\" + fileName + "RiskbarChart.png");
            File barChartFile = new File(IMG_PATH + fileName + "RiskbarChart.png");
            //File barChartFile = new File("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "RiskbarChart.png");

            ChartUtils.saveChartAsPNG(barChartFile, barChart, width, height);
        } catch (Exception e) {
            e.printStackTrace();
        }
        //dataMap.put("pic8", MDoc.getImageStr("C:\\Users\\96500\\Desktop\\test\\" + fileName + "RiskpieChart.png"));
        //dataMap.put("pic9", MDoc.getImageStr("C:\\Users\\96500\\Desktop\\test\\" + fileName + "RiskbarChart.png"));
        dataMap.put("pic8", MDoc.getImageStr(IMG_PATH + fileName + "RiskpieChart.png"));
        dataMap.put("pic9", MDoc.getImageStr(IMG_PATH + fileName + "RiskbarChart.png"));
        //dataMap.put("pic8", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "RiskpieChart.png"));
        //dataMap.put("pic9", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "RiskbarChart.png"));




        //第二部分，各部分工程检查情况
        String section2pName1 = "";
        List<Object> section2List = new ArrayList<Object>();
        for (int b = 0; b < name1Array.size(); b++) {
            Map<String, Object> section2Name1Map = new HashMap<String, Object>();
            List<Object> section2name1List = new ArrayList<Object>();
            String section2name1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(b));
            if (section2name1.equals("安全检查")) {
                section2pName1 = "安全问题";
            } else if (section2name1.equals("质量检查")) {
                section2pName1 = "质量问题";
            } else if (section2name1.equals("管理行为")) {
                section2pName1 = "管理体系及管理动作";
            }
            section2Name1Map.put("section2pName1", section2pName1);
            List<Object> section2Name4Info = problemCollectDetailMapper.getAllName4ByName1(checkId, section2name1);
            String section2Name44 = JSON.toJSONString(section2Name4Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray section2Name4Array = JSONArray.parseArray(section2Name44);
            for (int w = 0; w < section2Name4Array.size(); w++) {
                Map<String, Object> section2Name4Map = new HashMap<String, Object>();
                List<Object> section2Name4List = new ArrayList<Object>();
                int section2Name4Id = section2Name4Array.getIntValue(w);
                String section2Name4 = prefixsystemMapper.getName4ByName4Id(section2Name4Id);
                List<ProblemCollectDetail> section2Name6Info = problemCollectDetailMapper.getAllName6InfoByName4(checkId, section2Name4Id, section2name1);
                String section2Name66 = JSON.toJSONString(section2Name6Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray section2Name6Array = JSONArray.parseArray(section2Name66);
                for (int c = 0; c < section2Name6Array.size(); c++) {
                    Map<String, Object> section2Name6Map = new HashMap<String, Object>();
                    List<Object> picList = new ArrayList<Object>();
                    JSONObject section2Name6Object = section2Name6Array.getJSONObject(c);
                    section2Name6Map.put("section2pName6No", c + 1);
                    section2Name6Map.put("section2pName6", section2Name6Object.getString("pName6"));
                    section2Name6Map.put("section2pName5", section2Name6Object.getString("pName5"));
                    section2Name6Map.put("section2RiskLevel", section2Name6Object.getString("riskPoint"));
                    section2Name6Map.put("section2CheckPart", section2Name6Object.getString("checkPart"));
                    section2Name6Map.put("section2ProblemNum", section2Name6Object.getString("problemQua"));
                    if (section2Name6Object.getString("isRemark").equals("N")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("problemDescription"));
                    } else if (section2Name6Object.getString("isRemark").equals("Y")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("remark"));
                    }
                    section2Name6Map.put("section2normsProvison", section2Name6Object.getString("normsProvison"));
                    section2Name6Map.put("section2suggestion", section2Name6Object.getString("suggestion"));
                    String section2picPath = section2Name6Object.getString("picPath");
                    String picName = section2Name6Object.getString("picName");
                    JSONArray ja = JSONArray.parseArray(picName);
                    if (ja.size() == 0) {
                        //String s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                        String s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                        picList.add(s);
                    } else {
                        for (int o = 0; o < ja.size(); o++) {
                            String s="";
                            if( "prod".equals(profiles.getActives()) ){
                                s = MDoc.getImageStr(section2picPath + ja.getString(o));
                            }
                            picList.add(s);
                        }
                    }
                    section2Name6Map.put("picList", picList);
                    section2Name4List.add(section2Name6Map);

                }
                section2Name4Map.put("section2pName4", section2Name4);
                section2Name4Map.put("section2Name4List", section2Name4List);
                section2name1List.add(section2Name4Map);
            }
            section2Name1Map.put("section2Name1List", section2name1List);
            section2List.add(section2Name1Map);
        }
        try {
            JFreeChart chart = ChartFactory.createPieChart("现场施工问题分布饼图", datasetPie, true, true, false);
            final PiePlot plot = (PiePlot) chart.getPlot();
            plot.setStartAngle(270);
            plot.setForegroundAlpha(0.90f);
            plot.setInteriorGap(0.02);
            chart.getLegend().setVisible(false);
            //File pieChart = new File("C:\\Users\\96500\\Desktop\\test\\" + fileName + "pieChart.png");
            File pieChart = new File(IMG_PATH + fileName + "pieChart.png");
            //File pieChart = new File("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "pieChart.png");
            ChartUtils.saveChartAsPNG(pieChart, chart, width, height);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            JFreeChart barChart = ChartFactory.createBarChart("现场施工问题分布直方图",
                    "",
                    "数量",
                    datasetBar,
                    PlotOrientation.VERTICAL,
                    true, true, false);
            CategoryPlot plot = (CategoryPlot) barChart.getPlot();
            plot.getRenderer().setSeriesPaint(0, new Color(5, 87, 232));
            BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
            barRenderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
            barRenderer.setDefaultItemLabelsVisible(true);
            barRenderer.setItemLabelAnchorOffset(-20D);
            barRenderer.setMaximumBarWidth(0.2);
            CategoryAxis categoryAxis = plot.getDomainAxis();
            categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
            //File barChartFile = new File("C:\\Users\\96500\\Desktop\\test\\" + fileName + "barChart.png");
            File barChartFile = new File(IMG_PATH + fileName + "barChart.png");
            //File barChartFile = new File("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "barChart.png");

            ChartUtils.saveChartAsPNG(barChartFile, barChart, width, height);
        } catch (Exception e) {
            e.printStackTrace();
        }
        //dataMap.put("pic6", MDoc.getImageStr("C:\\Users\\96500\\Desktop\\test\\" + fileName + "pieChart.png"));
        //dataMap.put("pic7", MDoc.getImageStr("C:\\Users\\96500\\Desktop\\test\\" + fileName + "barChart.png"));
        dataMap.put("pic6", MDoc.getImageStr(IMG_PATH + fileName + "pieChart.png"));
        dataMap.put("pic7", MDoc.getImageStr(IMG_PATH + fileName + "barChart.png"));
        //dataMap.put("pic6", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "pieChart.png"));
        //dataMap.put("pic7", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "barChart.png"));


        dataMap.put("section2List", section2List);
        MDoc mdoc = new MDoc();
      /*  if (reportType == 1) {
            mdoc.createDoc(dataMap, "C:\\Users\\96500\\Desktop\\test\\" + fileName + ".doc", "ftl\\5.0.ftl");
            MDoc.docToDocx("C:\\Users\\96500\\Desktop\\test\\" + fileName + ".doc", "C:\\Users\\96500\\Desktop\\test\\" + fileName + ".doc");
        } else if (reportType == 2) {
            mdoc.createDoc(dataMap, "C:\\Users\\96500\\Desktop\\Risktest\\" + fileName + ".doc", "ftl\\Risk2.0.ftl");
            MDoc.docToDocx("C:\\Users\\96500\\Desktop\\Risktest\\" + fileName + ".doc", "C:\\Users\\96500\\Desktop\\Risktest\\" + fileName + ".doc");
        }
        return "success";*/
        String path = FileUtil.getServerFolderPath();
        File f1 = new File(path, "doc");
        if (!f1.exists()) {
            f1.mkdirs();
        }
        String result="";

            //mdoc.createDoc(dataMap, "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc", "ftl\\NewRisk2.0.ftl");
            //MDoc.docToDocx("E:\\tencent_File\\1296928795\\FileRecv\\yirui" + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc", "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc");
            //result = "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + projectObject.getString("projectName").replace('#','号')+"小结报告"+fileName + ".doc";
        mdoc.createDoc(dataMap, path + "\\doc\\" + projectObject.getString("projectName").replace('#','号')+"安全风险报告"+fileName + ".doc", "ftl\\NewRisk2.0.ftl");
        //MDoc.docToDocx("D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + projectObject.getString("projectName").replace('#','号')+"安全风险报告"+fileName + ".doc", "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\"+ projectObject.getString("projectName").replace('#','号')+"安全风险报告"+fileName +".doc");
        result=urlProperties.getAddress()+"/doc/"  + projectObject.getString("projectName").replace('#','号')+"安全风险报告"+fileName + ".doc";
//           mdoc.createDoc(dataMap, "D:\\WAAA\\新建文件夹" + "\\" + projectObject.getString("projectName").replace('#','号')+"隐患报告"+fileName + ".doc", "ftl\\Risk2.0.ftl");
//           MDoc.docToDocx("D:\\\\WAAA\\\\新建文件夹\\" + projectObject.getString("projectName").replace('#','号')+"隐患报告"+fileName + ".doc", "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\"+ projectObject.getString("projectName").replace('#','号')+"隐患报告"+fileName +".doc");

        return result;
    }
    @Override
    public boolean getIsNew(int checkId) {
        return problemcollectMapper.getIsNew(checkId) > 0 ? true :false;
    }

}
